; Fix backslashes in python-tests

* test/lisp/progmodes/python-tests.el (python-indent-after-backslash-1)
(python-indent-after-backslash-2)
(python-indent-after-backslash-3)
(python-indent-after-backslash-4)
(python-indent-after-backslash-5)
(python-nav-beginning-of-statement-1)
(python-nav-end-of-statement-1)
(python-nav-forward-statement-1)
(python-nav-backward-statement-1)
(python-nav-backward-statement-2)
(python-info-statement-starts-block-p-2)
(python-info-statement-ends-block-p-2)
(python-info-beginning-of-statement-p-2)
(python-info-end-of-statement-p-2)
(python-info-beginning-of-block-p-2)
(python-info-end-of-block-p-2)
(python-info-line-ends-backslash-p-1)
(python-info-beginning-of-backslash-1)
(python-info-continuation-line-p-1)
(python-info-block-continuation-line-p-1)
(python-info-assignment-statement-p-1)
(python-info-assignment-continuation-line-p-1): Backslashes in
literals should be doubled only once to produce one backslash in the
buffer.  If there backslashes inside a Python string literal in a Lisp
literal, that would need to be doubled twice, but there are no such
cases.  Note that `python-tests-looking-at' takes a plain string, not
a regexp.
This commit is contained in:
Noam Postavsky 2017-05-22 12:36:20 -04:00
parent eafc985f7e
commit 443f371636

View file

@ -654,8 +654,8 @@ async for a in sequencer():
"The most common case."
(python-tests-with-temp-buffer
"
from foo.bar.baz import something, something_1 \\\\
something_2 something_3, \\\\
from foo.bar.baz import something, something_1 \\
something_2 something_3, \\
something_4, something_5
"
(python-tests-look-at "from foo.bar.baz import something, something_1")
@ -675,14 +675,14 @@ from foo.bar.baz import something, something_1 \\\\
"A pretty extreme complicated case."
(python-tests-with-temp-buffer
"
objects = Thing.objects.all() \\\\
objects = Thing.objects.all() \\
.filter(
type='toy',
status='bought'
) \\\\
) \\
.aggregate(
Sum('amount')
) \\\\
) \\
.values_list()
"
(python-tests-look-at "objects = Thing.objects.all()")
@ -698,7 +698,7 @@ objects = Thing.objects.all() \\\\
(python-tests-look-at "status='bought'")
(should (eq (car (python-indent-context)) :inside-paren-newline-start))
(should (= (python-indent-calculate-indentation) 27))
(python-tests-look-at ") \\\\")
(python-tests-look-at ") \\")
(should (eq (car (python-indent-context)) :inside-paren-at-closing-paren))
(should (= (python-indent-calculate-indentation) 23))
(python-tests-look-at ".aggregate(")
@ -708,7 +708,7 @@ objects = Thing.objects.all() \\\\
(python-tests-look-at "Sum('amount')")
(should (eq (car (python-indent-context)) :inside-paren-newline-start))
(should (= (python-indent-calculate-indentation) 27))
(python-tests-look-at ") \\\\")
(python-tests-look-at ") \\")
(should (eq (car (python-indent-context)) :inside-paren-at-closing-paren))
(should (= (python-indent-calculate-indentation) 23))
(python-tests-look-at ".values_list()")
@ -723,12 +723,12 @@ objects = Thing.objects.all() \\\\
"Backslash continuation from block start."
(python-tests-with-temp-buffer
"
with open('/path/to/some/file/you/want/to/read') as file_1, \\\\
with open('/path/to/some/file/you/want/to/read') as file_1, \\
open('/path/to/some/file/being/written', 'w') as file_2:
file_2.write(file_1.read())
"
(python-tests-look-at
"with open('/path/to/some/file/you/want/to/read') as file_1, \\\\")
"with open('/path/to/some/file/you/want/to/read') as file_1, \\")
(should (eq (car (python-indent-context)) :no-indent))
(should (= (python-indent-calculate-indentation) 0))
(python-tests-look-at
@ -744,15 +744,15 @@ with open('/path/to/some/file/you/want/to/read') as file_1, \\\\
"Backslash continuation from assignment."
(python-tests-with-temp-buffer
"
super_awful_assignment = some_calculation() and \\\\
another_calculation() and \\\\
super_awful_assignment = some_calculation() and \\
another_calculation() and \\
some_final_calculation()
"
(python-tests-look-at
"super_awful_assignment = some_calculation() and \\\\")
"super_awful_assignment = some_calculation() and \\")
(should (eq (car (python-indent-context)) :no-indent))
(should (= (python-indent-calculate-indentation) 0))
(python-tests-look-at "another_calculation() and \\\\")
(python-tests-look-at "another_calculation() and \\")
(should (eq (car (python-indent-context))
:after-backslash-assignment-continuation))
(should (= (python-indent-calculate-indentation) python-indent-offset))
@ -765,14 +765,14 @@ super_awful_assignment = some_calculation() and \\\\
(python-tests-with-temp-buffer
"
def delete_all_things():
Thing \\\\
.objects.all() \\\\
Thing \\
.objects.all() \\
.delete()
"
(python-tests-look-at "Thing \\\\")
(python-tests-look-at "Thing \\")
(should (eq (car (python-indent-context)) :after-block-start))
(should (= (python-indent-calculate-indentation) 4))
(python-tests-look-at ".objects.all() \\\\")
(python-tests-look-at ".objects.all() \\")
(should (eq (car (python-indent-context)) :after-backslash-first-line))
(should (= (python-indent-calculate-indentation) 8))
(python-tests-look-at ".delete()")
@ -1874,8 +1874,8 @@ class A(object):
(ert-deftest python-nav-beginning-of-statement-1 ()
(python-tests-with-temp-buffer
"
v1 = 123 + \
456 + \
v1 = 123 + \\
456 + \\
789
v2 = (value1,
value2,
@ -1922,8 +1922,8 @@ string
(ert-deftest python-nav-end-of-statement-1 ()
(python-tests-with-temp-buffer
"
v1 = 123 + \
456 + \
v1 = 123 + \\
456 + \\
789
v2 = (value1,
value2,
@ -1976,8 +1976,8 @@ string
(ert-deftest python-nav-forward-statement-1 ()
(python-tests-with-temp-buffer
"
v1 = 123 + \
456 + \
v1 = 123 + \\
456 + \\
789
v2 = (value1,
value2,
@ -2017,8 +2017,8 @@ string
(ert-deftest python-nav-backward-statement-1 ()
(python-tests-with-temp-buffer
"
v1 = 123 + \
456 + \
v1 = 123 + \\
456 + \\
789
v2 = (value1,
value2,
@ -2059,8 +2059,8 @@ string
:expected-result :failed
(python-tests-with-temp-buffer
"
v1 = 123 + \
456 + \
v1 = 123 + \\
456 + \\
789
v2 = (value1,
value2,
@ -3954,8 +3954,8 @@ def long_function_name(
(ert-deftest python-info-statement-starts-block-p-2 ()
(python-tests-with-temp-buffer
"
if width == 0 and height == 0 and \\\\
color == 'red' and emphasis == 'strong' or \\\\
if width == 0 and height == 0 and \\
color == 'red' and emphasis == 'strong' or \\
highlight > 100:
raise ValueError('sorry, you lose')
"
@ -3979,8 +3979,8 @@ def long_function_name(
(ert-deftest python-info-statement-ends-block-p-2 ()
(python-tests-with-temp-buffer
"
if width == 0 and height == 0 and \\\\
color == 'red' and emphasis == 'strong' or \\\\
if width == 0 and height == 0 and \\
color == 'red' and emphasis == 'strong' or \\
highlight > 100:
raise ValueError(
'sorry, you lose'
@ -4010,8 +4010,8 @@ def long_function_name(
(ert-deftest python-info-beginning-of-statement-p-2 ()
(python-tests-with-temp-buffer
"
if width == 0 and height == 0 and \\\\
color == 'red' and emphasis == 'strong' or \\\\
if width == 0 and height == 0 and \\
color == 'red' and emphasis == 'strong' or \\
highlight > 100:
raise ValueError(
'sorry, you lose'
@ -4050,8 +4050,8 @@ def long_function_name(
(ert-deftest python-info-end-of-statement-p-2 ()
(python-tests-with-temp-buffer
"
if width == 0 and height == 0 and \\\\
color == 'red' and emphasis == 'strong' or \\\\
if width == 0 and height == 0 and \\
color == 'red' and emphasis == 'strong' or \\
highlight > 100:
raise ValueError(
'sorry, you lose'
@ -4091,8 +4091,8 @@ def long_function_name(
(ert-deftest python-info-beginning-of-block-p-2 ()
(python-tests-with-temp-buffer
"
if width == 0 and height == 0 and \\\\
color == 'red' and emphasis == 'strong' or \\\\
if width == 0 and height == 0 and \\
color == 'red' and emphasis == 'strong' or \\
highlight > 100:
raise ValueError(
'sorry, you lose'
@ -4129,8 +4129,8 @@ def long_function_name(
(ert-deftest python-info-end-of-block-p-2 ()
(python-tests-with-temp-buffer
"
if width == 0 and height == 0 and \\\\
color == 'red' and emphasis == 'strong' or \\\\
if width == 0 and height == 0 and \\
color == 'red' and emphasis == 'strong' or \\
highlight > 100:
raise ValueError(
'sorry, you lose'
@ -4637,14 +4637,14 @@ elif b:
(ert-deftest python-info-line-ends-backslash-p-1 ()
(python-tests-with-temp-buffer
"
objects = Thing.objects.all() \\\\
objects = Thing.objects.all() \\
.filter(
type='toy',
status='bought'
) \\\\
) \\
.aggregate(
Sum('amount')
) \\\\
) \\
.values_list()
"
(should (python-info-line-ends-backslash-p 2)) ; .filter(...
@ -4660,14 +4660,14 @@ objects = Thing.objects.all() \\\\
(ert-deftest python-info-beginning-of-backslash-1 ()
(python-tests-with-temp-buffer
"
objects = Thing.objects.all() \\\\
objects = Thing.objects.all() \\
.filter(
type='toy',
status='bought'
) \\\\
) \\
.aggregate(
Sum('amount')
) \\\\
) \\
.values_list()
"
(let ((first 2)
@ -4686,8 +4686,8 @@ objects = Thing.objects.all() \\\\
(ert-deftest python-info-continuation-line-p-1 ()
(python-tests-with-temp-buffer
"
if width == 0 and height == 0 and \\\\
color == 'red' and emphasis == 'strong' or \\\\
if width == 0 and height == 0 and \\
color == 'red' and emphasis == 'strong' or \\
highlight > 100:
raise ValueError(
'sorry, you lose'
@ -4714,8 +4714,8 @@ if width == 0 and height == 0 and \\\\
(ert-deftest python-info-block-continuation-line-p-1 ()
(python-tests-with-temp-buffer
"
if width == 0 and height == 0 and \\\\
color == 'red' and emphasis == 'strong' or \\\\
if width == 0 and height == 0 and \\
color == 'red' and emphasis == 'strong' or \\
highlight > 100:
raise ValueError(
'sorry, you lose'
@ -4749,8 +4749,8 @@ def foo(a,
(ert-deftest python-info-assignment-statement-p-1 ()
(python-tests-with-temp-buffer
"
data = foo(), bar() \\\\
baz(), 4 \\\\
data = foo(), bar() \\
baz(), 4 \\
5, 6
"
(python-tests-look-at "data = foo(), bar()")
@ -4792,8 +4792,8 @@ data '=' 42
(ert-deftest python-info-assignment-continuation-line-p-1 ()
(python-tests-with-temp-buffer
"
data = foo(), bar() \\\\
baz(), 4 \\\\
data = foo(), bar() \\
baz(), 4 \\
5, 6
"
(python-tests-look-at "data = foo(), bar()")