aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp/progmodes/python-tests.el
diff options
context:
space:
mode:
authorEli Zaretskii2023-06-03 05:50:58 -0400
committerEli Zaretskii2023-06-03 05:50:58 -0400
commit970f94a2dd8bc4be4d71f1075421093ca6f87d28 (patch)
tree56ad75121692fa68fd1ec158a6b975dd2e902cbd /test/lisp/progmodes/python-tests.el
parent68b87288aa54c2ec701fdf4333fc92e32313c83b (diff)
parentede3535051a8f3b209b830adcaba9cb1ddf58685 (diff)
downloademacs-970f94a2dd8bc4be4d71f1075421093ca6f87d28.tar.gz
emacs-970f94a2dd8bc4be4d71f1075421093ca6f87d28.zip
Merge from origin/emacs-29
ede3535051a ; Fix last change 8ec786349e1 Fix apostrophe handling in rust-ts-mode and go-ts-mode (B... 0eba9cf6511 * test/infra/Dockerfile.emba (emacs-base): Install also g... 4897c98b6c4 Fix 'python-util-clone-local-variables' 6b2c8dc9050 Revert "Enhance Python font-lock to support multilines" 348e4504c6d Fix typo in calc.texi 03663b8798a Update to Transient v0.4.1 dc7acb1aafe Avoid errors in 'delete-forward-char' deleting static com... 2f94f6de9d6 Make VS-15 and VS-16 compositions work correctly 753f8aa1f14 Fix project-name for vc-aware backend in non-file buffers 17c7915ab94 ; Fix 'package-install-upgrade-built-in' check for packag... e252ce26eab Add type_predicate 'is' as keyword in typescript-ts-mode ... 0a354d65784 Fix infloop in info-look.el 83b22139e4c Fix several todo-mode.el item editing bugs (bug#63811) ed4cd3eddf7 dockerfile-ts-mode: Prevent empty categories in imenu (Bu... 2e20e318da2 Brush up doc strings and terminology in plstore.el 372bc1278c2 Add internal documentation on plstore.el 23a14e7b902 Add compact_constructor_declaration font-locking to java-... 500abc4dc37 * lisp/tmm.el (tmm-completion-delete-prompt): Add more ch... afc1f329356 Allow to disable the DWIMish behavior of 'x' in package menu 08104c01504 Allow dired to invoke secondary browser a3063f0bc87 Add a binding for enriched-toggle-markup d8ba28fa394 Fix order of tmm-menubar when 'tmm-mid-prompt' is nil # Conflicts: # etc/NEWS
Diffstat (limited to 'test/lisp/progmodes/python-tests.el')
-rw-r--r--test/lisp/progmodes/python-tests.el144
1 files changed, 0 insertions, 144 deletions
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index b916232c4be..9323f72f384 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -136,20 +136,6 @@ STRING, it is skipped so the next STRING occurrence is selected."
136 while pos 136 while pos
137 collect (cons pos (get-text-property pos 'face)))) 137 collect (cons pos (get-text-property pos 'face))))
138 138
139(defun python-tests-assert-faces-after-change (content faces search replace)
140 "Assert that font faces for CONTENT are equal to FACES after change.
141All occurrences of SEARCH are changed to REPLACE."
142 (python-tests-with-temp-buffer
143 content
144 ;; Force enable font-lock mode without jit-lock.
145 (rename-buffer "*python-font-lock-test*" t)
146 (let (noninteractive font-lock-support-mode)
147 (font-lock-mode))
148 (while
149 (re-search-forward search nil t)
150 (replace-match replace))
151 (should (equal faces (python-tests-get-buffer-faces)))))
152
153(defun python-tests-self-insert (char-or-str) 139(defun python-tests-self-insert (char-or-str)
154 "Call `self-insert-command' for chars in CHAR-OR-STR." 140 "Call `self-insert-command' for chars in CHAR-OR-STR."
155 (let ((chars 141 (let ((chars
@@ -297,13 +283,6 @@ p = (1 + 2)
297 "def 1func():" 283 "def 1func():"
298 '((1 . font-lock-keyword-face) (4)))) 284 '((1 . font-lock-keyword-face) (4))))
299 285
300(ert-deftest python-font-lock-keywords-level-1-3 ()
301 (python-tests-assert-faces
302 "def \\
303 func():"
304 '((1 . font-lock-keyword-face) (4)
305 (15 . font-lock-function-name-face) (19))))
306
307(ert-deftest python-font-lock-assignment-statement-1 () 286(ert-deftest python-font-lock-assignment-statement-1 ()
308 (python-tests-assert-faces 287 (python-tests-assert-faces
309 "a, b, c = 1, 2, 3" 288 "a, b, c = 1, 2, 3"
@@ -495,129 +474,6 @@ def f(x: CustomInt) -> CustomInt:
495 (136 . font-lock-operator-face) (137) 474 (136 . font-lock-operator-face) (137)
496 (144 . font-lock-keyword-face) (150)))) 475 (144 . font-lock-keyword-face) (150))))
497 476
498(ert-deftest python-font-lock-assignment-statement-multiline-1 ()
499 (python-tests-assert-faces-after-change
500 "
501[
502 a,
503 b
504] # (
505 1,
506 2
507)
508"
509 '((1)
510 (8 . font-lock-variable-name-face) (9)
511 (15 . font-lock-variable-name-face) (16)
512 (19 . font-lock-operator-face) (20))
513 "#" "="))
514
515(ert-deftest python-font-lock-assignment-statement-multiline-2 ()
516 (python-tests-assert-faces-after-change
517 "
518[
519 *a
520] # 5, 6
521"
522 '((1)
523 (8 . font-lock-operator-face)
524 (9 . font-lock-variable-name-face) (10)
525 (13 . font-lock-operator-face) (14))
526 "#" "="))
527
528(ert-deftest python-font-lock-assignment-statement-multiline-3 ()
529 (python-tests-assert-faces-after-change
530 "a\\
531 ,\\
532 b\\
533 ,\\
534 c\\
535 #\\
536 1\\
537 ,\\
538 2\\
539 ,\\
540 3"
541 '((1 . font-lock-variable-name-face) (2)
542 (15 . font-lock-variable-name-face) (16)
543 (29 . font-lock-variable-name-face) (30)
544 (36 . font-lock-operator-face) (37))
545 "#" "="))
546
547(ert-deftest python-font-lock-assignment-statement-multiline-4 ()
548 (python-tests-assert-faces-after-change
549 "a\\
550 :\\
551 int\\
552 #\\
553 5"
554 '((1 . font-lock-variable-name-face) (2)
555 (15 . font-lock-builtin-face) (18)
556 (24 . font-lock-operator-face) (25))
557 "#" "="))
558
559(ert-deftest python-font-lock-assignment-statement-multiline-5 ()
560 (python-tests-assert-faces-after-change
561 "(\\
562 a\\
563)\\
564 #\\
565 5\\
566 ;\\
567 (\\
568 b\\
569 )\\
570 #\\
571 6"
572 '((1)
573 (8 . font-lock-variable-name-face) (9)
574 (18 . font-lock-operator-face) (19)
575 (46 . font-lock-variable-name-face) (47)
576 (60 . font-lock-operator-face) (61))
577 "#" "="))
578
579(ert-deftest python-font-lock-assignment-statement-multiline-6 ()
580 (python-tests-assert-faces-after-change
581 "(
582 a
583)\\
584 #\\
585 5\\
586 ;\\
587 (
588 b
589 )\\
590 #\\
591 6"
592 '((1)
593 (7 . font-lock-variable-name-face) (8)
594 (16 . font-lock-operator-face) (17)
595 (43 . font-lock-variable-name-face) (44)
596 (56 . font-lock-operator-face) (57))
597 "#" "="))
598
599(ert-deftest python-font-lock-operator-1 ()
600 (python-tests-assert-faces
601 "1 << 2 ** 3 == +4%-5|~6&7^8%9"
602 '((1)
603 (3 . font-lock-operator-face) (5)
604 (8 . font-lock-operator-face) (10)
605 (13 . font-lock-operator-face) (15)
606 (16 . font-lock-operator-face) (17)
607 (18 . font-lock-operator-face) (20)
608 (21 . font-lock-operator-face) (23)
609 (24 . font-lock-operator-face) (25)
610 (26 . font-lock-operator-face) (27)
611 (28 . font-lock-operator-face) (29))))
612
613(ert-deftest python-font-lock-operator-2 ()
614 "Keyword operators are font-locked as keywords."
615 (python-tests-assert-faces
616 "is_ is None"
617 '((1)
618 (5 . font-lock-keyword-face) (7)
619 (8 . font-lock-constant-face))))
620
621(ert-deftest python-font-lock-escape-sequence-string-newline () 477(ert-deftest python-font-lock-escape-sequence-string-newline ()
622 (python-tests-assert-faces 478 (python-tests-assert-faces
623 "'\\n' 479 "'\\n'