aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp/progmodes/python-tests.el
diff options
context:
space:
mode:
authorkobarity2022-07-03 14:22:13 +0200
committerLars Ingebrigtsen2022-07-03 14:23:25 +0200
commit6e2f9dd3dd8b3c65608366039ce69666905d80cb (patch)
tree5231d795049ffc2314b0f5198ff773f6739caf3e /test/lisp/progmodes/python-tests.el
parentc61c647f7272faf625b5584035d455e81d1ebd0e (diff)
downloademacs-6e2f9dd3dd8b3c65608366039ce69666905d80cb.tar.gz
emacs-6e2f9dd3dd8b3c65608366039ce69666905d80cb.zip
Fix `python-nav-beginning-of-defun' line continuation using backslash
* lisp/progmodes/python.el (python-nav--beginning-of-defun): Allow line continuation using backslash in defuns (bug#55702). (python-info-looking-at-beginning-of-defun): Add CHECK-STATEMENT argument.
Diffstat (limited to 'test/lisp/progmodes/python-tests.el')
-rw-r--r--test/lisp/progmodes/python-tests.el81
1 files changed, 79 insertions, 2 deletions
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index c59a2e79533..d7b3c102f2d 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -1757,6 +1757,36 @@ def foo(x):
1757 (should (= (marker-position (mark-marker)) 1757 (should (= (marker-position (mark-marker))
1758 expected-mark-end-position))))) 1758 expected-mark-end-position)))))
1759 1759
1760(ert-deftest python-mark-defun-5 ()
1761 "Test `python-mark-defun' with point inside backslash escaped defun."
1762 (python-tests-with-temp-buffer
1763 "
1764def \\
1765 foo(x):
1766 return x
1767"
1768 (let ((transient-mark-mode t)
1769 (expected-mark-beginning-position
1770 (progn
1771 (python-tests-look-at "def ")
1772 (1- (line-beginning-position))))
1773 (expected-mark-end-position
1774 (save-excursion
1775 (python-tests-look-at "return x")
1776 (forward-line)
1777 (point))))
1778 (python-tests-look-at "def ")
1779 (python-mark-defun 1)
1780 (should (= (point) expected-mark-beginning-position))
1781 (should (= (marker-position (mark-marker))
1782 expected-mark-end-position))
1783 (deactivate-mark)
1784 (python-tests-look-at "foo(x)")
1785 (python-mark-defun 1)
1786 (should (= (point) expected-mark-beginning-position))
1787 (should (= (marker-position (mark-marker))
1788 expected-mark-end-position)))))
1789
1760 1790
1761;;; Navigation 1791;;; Navigation
1762 1792
@@ -1905,17 +1935,47 @@ class C(object):
1905(ert-deftest python-nav-beginning-of-defun-4 () 1935(ert-deftest python-nav-beginning-of-defun-4 ()
1906 (python-tests-with-temp-buffer 1936 (python-tests-with-temp-buffer
1907 " 1937 "
1938def a():
1939 pass
1940
1908def \\ 1941def \\
1909 a(): 1942 b():
1910 return 0 1943 return 0
1944
1945def c():
1946 pass
1911" 1947"
1912 (python-tests-look-at "return 0") 1948 (python-tests-look-at "def c():")
1949 (should (= (save-excursion
1950 (python-nav-beginning-of-defun)
1951 (point))
1952 (save-excursion
1953 (python-tests-look-at "def \\" -1)
1954 (beginning-of-line)
1955 (point))))
1956 (python-tests-look-at "return 0" -1)
1913 (should (= (save-excursion 1957 (should (= (save-excursion
1914 (python-nav-beginning-of-defun) 1958 (python-nav-beginning-of-defun)
1915 (point)) 1959 (point))
1916 (save-excursion 1960 (save-excursion
1917 (python-tests-look-at "def \\" -1) 1961 (python-tests-look-at "def \\" -1)
1918 (beginning-of-line) 1962 (beginning-of-line)
1963 (point))))
1964 (python-tests-look-at "b():" -1)
1965 (should (= (save-excursion
1966 (python-nav-beginning-of-defun)
1967 (point))
1968 (save-excursion
1969 (python-tests-look-at "def \\" -1)
1970 (beginning-of-line)
1971 (point))))
1972 (python-tests-look-at "def a():" -1)
1973 (should (= (save-excursion
1974 (python-nav-beginning-of-defun -1)
1975 (point))
1976 (save-excursion
1977 (python-tests-look-at "def \\")
1978 (beginning-of-line)
1919 (point)))))) 1979 (point))))))
1920 1980
1921(ert-deftest python-nav-end-of-defun-1 () 1981(ert-deftest python-nav-end-of-defun-1 ()
@@ -5242,6 +5302,23 @@ def decorat0r(deff):
5242 (python-tests-look-at "deff()") 5302 (python-tests-look-at "deff()")
5243 (should (not (python-info-looking-at-beginning-of-defun))))) 5303 (should (not (python-info-looking-at-beginning-of-defun)))))
5244 5304
5305(ert-deftest python-info-looking-at-beginning-of-defun-2 ()
5306 (python-tests-with-temp-buffer
5307 "
5308def \\
5309 foo(arg):
5310 pass
5311"
5312 (python-tests-look-at "def \\")
5313 (should (python-info-looking-at-beginning-of-defun))
5314 (should (python-info-looking-at-beginning-of-defun nil t))
5315 (python-tests-look-at "foo(arg):")
5316 (should (not (python-info-looking-at-beginning-of-defun)))
5317 (should (python-info-looking-at-beginning-of-defun nil t))
5318 (python-tests-look-at "pass")
5319 (should (not (python-info-looking-at-beginning-of-defun)))
5320 (should (not (python-info-looking-at-beginning-of-defun nil t)))))
5321
5245(ert-deftest python-info-current-line-comment-p-1 () 5322(ert-deftest python-info-current-line-comment-p-1 ()
5246 (python-tests-with-temp-buffer 5323 (python-tests-with-temp-buffer
5247 " 5324 "