aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp/progmodes/python-tests.el
diff options
context:
space:
mode:
authorkobarity2024-01-06 22:04:42 +0900
committerEli Zaretskii2024-01-13 11:33:19 +0200
commitf2cc8ee2a1a106f9045447a1a025572d7938647e (patch)
treea424109d2f98a5ce2dc2ec3038409ff8979b315c /test/lisp/progmodes/python-tests.el
parent893829021bd50604b035c058814f280c7386aa46 (diff)
downloademacs-f2cc8ee2a1a106f9045447a1a025572d7938647e.tar.gz
emacs-f2cc8ee2a1a106f9045447a1a025572d7938647e.zip
Fix 'python-info-docstring-p' bug in the 2nd line of a buffer
* lisp/progmodes/python.el (python-info-docstring-p): Add 'looking-at-p' check when bobp. * test/lisp/progmodes/python-tests.el (python-font-lock-operator-1) (python-font-lock-operator-2): Restoration of ERTs deleted by mistake. (python-font-lock-escape-sequence-bytes-newline) (python-font-lock-escape-sequence-hex-octal) (python-font-lock-escape-sequence-unicode) (python-font-lock-raw-escape-sequence): Change 'font-lock-doc-face' to 'font-lock-string-face' and remove :expected-result :failed. (python-info-docstring-p-8): New test. (Bug#68284)
Diffstat (limited to 'test/lisp/progmodes/python-tests.el')
-rw-r--r--test/lisp/progmodes/python-tests.el73
1 files changed, 50 insertions, 23 deletions
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index 1df0c42a0ce..97ffd5fe20f 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -474,6 +474,28 @@ def f(x: CustomInt) -> CustomInt:
474 (136 . font-lock-operator-face) (137) 474 (136 . font-lock-operator-face) (137)
475 (144 . font-lock-keyword-face) (150)))) 475 (144 . font-lock-keyword-face) (150))))
476 476
477(ert-deftest python-font-lock-operator-1 ()
478 (python-tests-assert-faces
479 "1 << 2 ** 3 == +4%-5|~6&7^8%9"
480 '((1)
481 (3 . font-lock-operator-face) (5)
482 (8 . font-lock-operator-face) (10)
483 (13 . font-lock-operator-face) (15)
484 (16 . font-lock-operator-face) (17)
485 (18 . font-lock-operator-face) (20)
486 (21 . font-lock-operator-face) (23)
487 (24 . font-lock-operator-face) (25)
488 (26 . font-lock-operator-face) (27)
489 (28 . font-lock-operator-face) (29))))
490
491(ert-deftest python-font-lock-operator-2 ()
492 "Keyword operators are font-locked as keywords."
493 (python-tests-assert-faces
494 "is_ is None"
495 '((1)
496 (5 . font-lock-keyword-face) (7)
497 (8 . font-lock-constant-face))))
498
477(ert-deftest python-font-lock-escape-sequence-string-newline () 499(ert-deftest python-font-lock-escape-sequence-string-newline ()
478 (python-tests-assert-faces 500 (python-tests-assert-faces
479 "'\\n' 501 "'\\n'
@@ -585,62 +607,58 @@ u\"\\n\""
585 (845 . font-lock-string-face) (886)))) 607 (845 . font-lock-string-face) (886))))
586 608
587(ert-deftest python-font-lock-escape-sequence-bytes-newline () 609(ert-deftest python-font-lock-escape-sequence-bytes-newline ()
588 :expected-result :failed
589 (python-tests-assert-faces 610 (python-tests-assert-faces
590 "b'\\n' 611 "b'\\n'
591b\"\\n\"" 612b\"\\n\""
592 '((1) 613 '((1)
593 (2 . font-lock-doc-face) 614 (2 . font-lock-string-face)
594 (3 . font-lock-constant-face) 615 (3 . font-lock-constant-face)
595 (5 . font-lock-doc-face) (6) 616 (5 . font-lock-string-face) (6)
596 (8 . font-lock-doc-face) 617 (8 . font-lock-string-face)
597 (9 . font-lock-constant-face) 618 (9 . font-lock-constant-face)
598 (11 . font-lock-doc-face)))) 619 (11 . font-lock-string-face))))
599 620
600(ert-deftest python-font-lock-escape-sequence-hex-octal () 621(ert-deftest python-font-lock-escape-sequence-hex-octal ()
601 :expected-result :failed
602 (python-tests-assert-faces 622 (python-tests-assert-faces
603 "b'\\x12 \\777 \\1\\23' 623 "b'\\x12 \\777 \\1\\23'
604'\\x12 \\777 \\1\\23'" 624'\\x12 \\777 \\1\\23'"
605 '((1) 625 '((1)
606 (2 . font-lock-doc-face) 626 (2 . font-lock-string-face)
607 (3 . font-lock-constant-face) 627 (3 . font-lock-constant-face)
608 (7 . font-lock-doc-face) 628 (7 . font-lock-string-face)
609 (8 . font-lock-constant-face) 629 (8 . font-lock-constant-face)
610 (12 . font-lock-doc-face) 630 (12 . font-lock-string-face)
611 (13 . font-lock-constant-face) 631 (13 . font-lock-constant-face)
612 (18 . font-lock-doc-face) (19) 632 (18 . font-lock-string-face) (19)
613 (20 . font-lock-doc-face) 633 (20 . font-lock-string-face)
614 (21 . font-lock-constant-face) 634 (21 . font-lock-constant-face)
615 (25 . font-lock-doc-face) 635 (25 . font-lock-string-face)
616 (26 . font-lock-constant-face) 636 (26 . font-lock-constant-face)
617 (30 . font-lock-doc-face) 637 (30 . font-lock-string-face)
618 (31 . font-lock-constant-face) 638 (31 . font-lock-constant-face)
619 (36 . font-lock-doc-face)))) 639 (36 . font-lock-string-face))))
620 640
621(ert-deftest python-font-lock-escape-sequence-unicode () 641(ert-deftest python-font-lock-escape-sequence-unicode ()
622 :expected-result :failed
623 (python-tests-assert-faces 642 (python-tests-assert-faces
624 "b'\\u1234 \\U00010348 \\N{Plus-Minus Sign}' 643 "b'\\u1234 \\U00010348 \\N{Plus-Minus Sign}'
625'\\u1234 \\U00010348 \\N{Plus-Minus Sign}'" 644'\\u1234 \\U00010348 \\N{Plus-Minus Sign}'"
626 '((1) 645 '((1)
627 (2 . font-lock-doc-face) (41) 646 (2 . font-lock-string-face) (41)
628 (42 . font-lock-doc-face) 647 (42 . font-lock-string-face)
629 (43 . font-lock-constant-face) 648 (43 . font-lock-constant-face)
630 (49 . font-lock-doc-face) 649 (49 . font-lock-string-face)
631 (50 . font-lock-constant-face) 650 (50 . font-lock-constant-face)
632 (60 . font-lock-doc-face) 651 (60 . font-lock-string-face)
633 (61 . font-lock-constant-face) 652 (61 . font-lock-constant-face)
634 (80 . font-lock-doc-face)))) 653 (80 . font-lock-string-face))))
635 654
636(ert-deftest python-font-lock-raw-escape-sequence () 655(ert-deftest python-font-lock-raw-escape-sequence ()
637 :expected-result :failed
638 (python-tests-assert-faces 656 (python-tests-assert-faces
639 "rb'\\x12 \123 \\n' 657 "rb'\\x12 \123 \\n'
640r'\\x12 \123 \\n \\u1234 \\U00010348 \\N{Plus-Minus Sign}'" 658r'\\x12 \123 \\n \\u1234 \\U00010348 \\N{Plus-Minus Sign}'"
641 '((1) 659 '((1)
642 (3 . font-lock-doc-face) (14) 660 (3 . font-lock-string-face) (14)
643 (16 . font-lock-doc-face)))) 661 (16 . font-lock-string-face))))
644 662
645 663
646;;; Indentation 664;;; Indentation
@@ -6647,6 +6665,15 @@ class Class:
6647 (python-tests-look-at "Also not a docstring") 6665 (python-tests-look-at "Also not a docstring")
6648 (should-not (python-info-docstring-p)))) 6666 (should-not (python-info-docstring-p))))
6649 6667
6668(ert-deftest python-info-docstring-p-8 ()
6669 "Test string in the 2nd line of a buffer."
6670 (python-tests-with-temp-buffer
6671 "import sys
6672'''Not a docstring.'''
6673"
6674 (python-tests-look-at "Not a docstring")
6675 (should-not (python-info-docstring-p))))
6676
6650(ert-deftest python-info-triple-quoted-string-p-1 () 6677(ert-deftest python-info-triple-quoted-string-p-1 ()
6651 "Test triple quoted string." 6678 "Test triple quoted string."
6652 (python-tests-with-temp-buffer 6679 (python-tests-with-temp-buffer