1 ;;; python-tests.el --- Test suite for python.el
3 ;; Copyright (C) 2013 Free Software Foundation, Inc.
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs is free software: you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 3 of the License, or
10 ;; (at your option) any later version.
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 (defmacro python-tests-with-temp-buffer
(contents &rest body
)
27 "Create a `python-mode' enabled temp buffer with CONTENTS.
28 BODY is code to be executed within the temp buffer. Point is
29 always located at the beginning of buffer."
30 (declare (indent 1) (debug t
))
34 (goto-char (point-min))
37 (defmacro python-tests-with-temp-file
(contents &rest body
)
38 "Create a `python-mode' enabled file with CONTENTS.
39 BODY is code to be executed within the temp buffer. Point is
40 always located at the beginning of buffer."
41 (declare (indent 1) (debug t
))
42 ;; temp-file never actually used for anything?
43 `(let* ((temp-file (make-temp-file "python-tests" nil
".py"))
44 (buffer (find-file-noselect temp-file
)))
46 (with-current-buffer buffer
49 (goto-char (point-min))
51 (and buffer
(kill-buffer buffer
))
52 (delete-file temp-file
))))
54 (defun python-tests-look-at (string &optional num restore-point
)
55 "Move point at beginning of STRING in the current buffer.
56 Optional argument NUM defaults to 1 and is an integer indicating
57 how many occurrences must be found, when positive the search is
58 done forwards, otherwise backwards. When RESTORE-POINT is
59 non-nil the point is not moved but the position found is still
60 returned. When searching forward and point is already looking at
61 STRING, it is skipped so the next STRING occurrence is selected."
62 (let* ((num (or num
1))
63 (starting-point (point))
64 (string (regexp-quote string
))
65 (search-fn (if (> num
0) #'re-search-forward
#'re-search-backward
))
66 (deinc-fn (if (> num
0) #'1-
#'1+))
70 (while (not (= num
0))
73 ;; Moving forward and already looking at STRING, skip it.
74 (forward-char (length (match-string-no-properties 0))))
75 (and (not (funcall search-fn string nil t
))
78 ;; `re-search-forward' leaves point at the end of the
79 ;; occurrence, move back so point is at the beginning
81 (forward-char (- (length (match-string-no-properties 0)))))
83 num
(funcall deinc-fn num
)
84 found-point
(point))))
86 (and restore-point
(goto-char starting-point
)))))
89 ;;; Tests for your tests, so you can test while you test.
91 (ert-deftest python-tests-look-at-1
()
92 "Test forward movement."
93 (python-tests-with-temp-buffer
94 "Lorem ipsum dolor sit amet, consectetur adipisicing elit,
95 sed do eiusmod tempor incididunt ut labore et dolore magna
97 (let ((expected (save-excursion
99 (re-search-forward "et" nil t
))
102 (should (= (python-tests-look-at "et" 3 t
) expected
))
103 ;; Even if NUM is bigger than found occurrences the point of last
104 ;; one should be returned.
105 (should (= (python-tests-look-at "et" 6 t
) expected
))
106 ;; If already looking at STRING, it should skip it.
107 (dotimes (i 2) (re-search-forward "et"))
109 (should (= (python-tests-look-at "et") expected
)))))
111 (ert-deftest python-tests-look-at-2
()
112 "Test backward movement."
113 (python-tests-with-temp-buffer
114 "Lorem ipsum dolor sit amet, consectetur adipisicing elit,
115 sed do eiusmod tempor incididunt ut labore et dolore magna
119 (re-search-forward "et" nil t
)
123 (re-search-forward "et" nil t
))
124 (should (= (python-tests-look-at "et" -
3 t
) expected
))
125 (should (= (python-tests-look-at "et" -
6 t
) expected
)))))
131 ;;; Python specialized rx
134 ;;; Font-lock and syntax
139 ;; See: http://www.python.org/dev/peps/pep-0008/#indentation
141 (ert-deftest python-indent-pep8-1
()
143 (python-tests-with-temp-buffer
144 "# Aligned with opening delimiter
145 foo = long_function_name(var_one, var_two,
148 (should (eq (car (python-indent-context)) 'no-indent
))
149 (should (= (python-indent-calculate-indentation) 0))
150 (python-tests-look-at "foo = long_function_name(var_one, var_two,")
151 (should (eq (car (python-indent-context)) 'after-line
))
152 (should (= (python-indent-calculate-indentation) 0))
153 (python-tests-look-at "var_three, var_four)")
154 (should (eq (car (python-indent-context)) 'inside-paren
))
155 (should (= (python-indent-calculate-indentation) 25))))
157 (ert-deftest python-indent-pep8-2
()
159 (python-tests-with-temp-buffer
160 "# More indentation included to distinguish this from the rest.
161 def long_function_name(
162 var_one, var_two, var_three,
166 (should (eq (car (python-indent-context)) 'no-indent
))
167 (should (= (python-indent-calculate-indentation) 0))
168 (python-tests-look-at "def long_function_name(")
169 (should (eq (car (python-indent-context)) 'after-line
))
170 (should (= (python-indent-calculate-indentation) 0))
171 (python-tests-look-at "var_one, var_two, var_three,")
172 (should (eq (car (python-indent-context)) 'inside-paren
))
173 (should (= (python-indent-calculate-indentation) 8))
174 (python-tests-look-at "var_four):")
175 (should (eq (car (python-indent-context)) 'inside-paren
))
176 (should (= (python-indent-calculate-indentation) 8))
177 (python-tests-look-at "print (var_one)")
178 (should (eq (car (python-indent-context)) 'after-beginning-of-block
))
179 (should (= (python-indent-calculate-indentation) 4))))
181 (ert-deftest python-indent-pep8-3
()
183 (python-tests-with-temp-buffer
184 "# Extra indentation is not necessary.
185 foo = long_function_name(
189 (should (eq (car (python-indent-context)) 'no-indent
))
190 (should (= (python-indent-calculate-indentation) 0))
191 (python-tests-look-at "foo = long_function_name(")
192 (should (eq (car (python-indent-context)) 'after-line
))
193 (should (= (python-indent-calculate-indentation) 0))
194 (python-tests-look-at "var_one, var_two,")
195 (should (eq (car (python-indent-context)) 'inside-paren
))
196 (should (= (python-indent-calculate-indentation) 4))
197 (python-tests-look-at "var_three, var_four)")
198 (should (eq (car (python-indent-context)) 'inside-paren
))
199 (should (= (python-indent-calculate-indentation) 4))))
201 (ert-deftest python-indent-inside-paren-1
()
202 "The most simple inside-paren case that shouldn't fail."
203 (python-tests-with-temp-buffer
221 (python-tests-look-at "data = {")
222 (should (eq (car (python-indent-context)) 'after-line
))
223 (should (= (python-indent-calculate-indentation) 0))
224 (python-tests-look-at "'key':")
225 (should (eq (car (python-indent-context)) 'inside-paren
))
226 (should (= (python-indent-calculate-indentation) 4))
227 (python-tests-look-at "{")
228 (should (eq (car (python-indent-context)) 'inside-paren
))
229 (should (= (python-indent-calculate-indentation) 4))
230 (python-tests-look-at "'objlist': [")
231 (should (eq (car (python-indent-context)) 'inside-paren
))
232 (should (= (python-indent-calculate-indentation) 8))
233 (python-tests-look-at "{")
234 (should (eq (car (python-indent-context)) 'inside-paren
))
235 (should (= (python-indent-calculate-indentation) 12))
236 (python-tests-look-at "'pk': 1,")
237 (should (eq (car (python-indent-context)) 'inside-paren
))
238 (should (= (python-indent-calculate-indentation) 16))
239 (python-tests-look-at "'name': 'first',")
240 (should (eq (car (python-indent-context)) 'inside-paren
))
241 (should (= (python-indent-calculate-indentation) 16))
242 (python-tests-look-at "},")
243 (should (eq (car (python-indent-context)) 'inside-paren
))
244 (should (= (python-indent-calculate-indentation) 12))
245 (python-tests-look-at "{")
246 (should (eq (car (python-indent-context)) 'inside-paren
))
247 (should (= (python-indent-calculate-indentation) 12))
248 (python-tests-look-at "'pk': 2,")
249 (should (eq (car (python-indent-context)) 'inside-paren
))
250 (should (= (python-indent-calculate-indentation) 16))
251 (python-tests-look-at "'name': 'second',")
252 (should (eq (car (python-indent-context)) 'inside-paren
))
253 (should (= (python-indent-calculate-indentation) 16))
254 (python-tests-look-at "}")
255 (should (eq (car (python-indent-context)) 'inside-paren
))
256 (should (= (python-indent-calculate-indentation) 12))
257 (python-tests-look-at "]")
258 (should (eq (car (python-indent-context)) 'inside-paren
))
259 (should (= (python-indent-calculate-indentation) 8))
260 (python-tests-look-at "}")
261 (should (eq (car (python-indent-context)) 'inside-paren
))
262 (should (= (python-indent-calculate-indentation) 4))
263 (python-tests-look-at "}")
264 (should (eq (car (python-indent-context)) 'inside-paren
))
265 (should (= (python-indent-calculate-indentation) 0))))
267 (ert-deftest python-indent-inside-paren-2
()
268 "Another more compact paren group style."
269 (python-tests-with-temp-buffer
280 (python-tests-look-at "data = {")
281 (should (eq (car (python-indent-context)) 'after-line
))
282 (should (= (python-indent-calculate-indentation) 0))
283 (python-tests-look-at "'objlist': [")
284 (should (eq (car (python-indent-context)) 'inside-paren
))
285 (should (= (python-indent-calculate-indentation) 4))
286 (python-tests-look-at "{'pk': 1,")
287 (should (eq (car (python-indent-context)) 'inside-paren
))
288 (should (= (python-indent-calculate-indentation) 8))
289 (python-tests-look-at "'name': 'first'},")
290 (should (eq (car (python-indent-context)) 'inside-paren
))
291 (should (= (python-indent-calculate-indentation) 9))
292 (python-tests-look-at "{'pk': 2,")
293 (should (eq (car (python-indent-context)) 'inside-paren
))
294 (should (= (python-indent-calculate-indentation) 8))
295 (python-tests-look-at "'name': 'second'}")
296 (should (eq (car (python-indent-context)) 'inside-paren
))
297 (should (= (python-indent-calculate-indentation) 9))
298 (python-tests-look-at "]")
299 (should (eq (car (python-indent-context)) 'inside-paren
))
300 (should (= (python-indent-calculate-indentation) 4))
301 (python-tests-look-at "}}")
302 (should (eq (car (python-indent-context)) 'inside-paren
))
303 (should (= (python-indent-calculate-indentation) 0))
304 (python-tests-look-at "}")
305 (should (eq (car (python-indent-context)) 'inside-paren
))
306 (should (= (python-indent-calculate-indentation) 0))))
308 (ert-deftest python-indent-after-block-1
()
309 "The most simple after-block case that shouldn't fail."
310 (python-tests-with-temp-buffer
312 def foo(a, b, c=True):
314 (should (eq (car (python-indent-context)) 'no-indent
))
315 (should (= (python-indent-calculate-indentation) 0))
316 (goto-char (point-max))
317 (should (eq (car (python-indent-context)) 'after-beginning-of-block
))
318 (should (= (python-indent-calculate-indentation) 4))))
320 (ert-deftest python-indent-after-block-2
()
321 "A weird (malformed) multiline block statement."
322 (python-tests-with-temp-buffer
328 (goto-char (point-max))
329 (should (eq (car (python-indent-context)) 'after-beginning-of-block
))
330 (should (= (python-indent-calculate-indentation) 4))))
332 (ert-deftest python-indent-dedenters-1
()
333 "Check all dedenters."
334 (python-tests-with-temp-buffer
344 except (IndexError, AttributeError):
347 print ('nor a, nor b are true')
349 (python-tests-look-at "if a:")
350 (should (eq (car (python-indent-context)) 'after-beginning-of-block
))
351 (should (= (python-indent-calculate-indentation) 4))
352 (python-tests-look-at "print (a)")
353 (should (eq (car (python-indent-context)) 'after-beginning-of-block
))
354 (should (= (python-indent-calculate-indentation) 8))
355 (python-tests-look-at "elif b:")
356 (should (eq (car (python-indent-context)) 'after-line
))
357 (should (= (python-indent-calculate-indentation) 4))
358 (python-tests-look-at "print (b)")
359 (should (eq (car (python-indent-context)) 'after-beginning-of-block
))
360 (should (= (python-indent-calculate-indentation) 8))
361 (python-tests-look-at "else:")
362 (should (eq (car (python-indent-context)) 'after-line
))
363 (should (= (python-indent-calculate-indentation) 4))
364 (python-tests-look-at "try:")
365 (should (eq (car (python-indent-context)) 'after-beginning-of-block
))
366 (should (= (python-indent-calculate-indentation) 8))
367 (python-tests-look-at "print (c.pop())")
368 (should (eq (car (python-indent-context)) 'after-beginning-of-block
))
369 (should (= (python-indent-calculate-indentation) 12))
370 (python-tests-look-at "except (IndexError, AttributeError):")
371 (should (eq (car (python-indent-context)) 'after-line
))
372 (should (= (python-indent-calculate-indentation) 8))
373 (python-tests-look-at "print (c)")
374 (should (eq (car (python-indent-context)) 'after-beginning-of-block
))
375 (should (= (python-indent-calculate-indentation) 12))
376 (python-tests-look-at "finally:")
377 (should (eq (car (python-indent-context)) 'after-line
))
378 (should (= (python-indent-calculate-indentation) 8))
379 (python-tests-look-at "print ('nor a, nor b are true')")
380 (should (eq (car (python-indent-context)) 'after-beginning-of-block
))
381 (should (= (python-indent-calculate-indentation) 12))))
383 (ert-deftest python-indent-after-backslash-1
()
384 "The most common case."
385 (python-tests-with-temp-buffer
387 from foo.bar.baz import something, something_1 \\\\
388 something_2 something_3, \\\\
389 something_4, something_5
391 (python-tests-look-at "from foo.bar.baz import something, something_1")
392 (should (eq (car (python-indent-context)) 'after-line
))
393 (should (= (python-indent-calculate-indentation) 0))
394 (python-tests-look-at "something_2 something_3,")
395 (should (eq (car (python-indent-context)) 'after-backslash
))
396 (should (= (python-indent-calculate-indentation) 4))
397 (python-tests-look-at "something_4, something_5")
398 (should (eq (car (python-indent-context)) 'after-backslash
))
399 (should (= (python-indent-calculate-indentation) 4))
400 (goto-char (point-max))
401 (should (eq (car (python-indent-context)) 'after-line
))
402 (should (= (python-indent-calculate-indentation) 0))))
404 (ert-deftest python-indent-after-backslash-2
()
405 "A pretty extreme complicated case."
406 (python-tests-with-temp-buffer
408 objects = Thing.objects.all() \\\\
418 (python-tests-look-at "objects = Thing.objects.all()")
419 (should (eq (car (python-indent-context)) 'after-line
))
420 (should (= (python-indent-calculate-indentation) 0))
421 (python-tests-look-at ".filter(")
422 (should (eq (car (python-indent-context)) 'after-backslash
))
423 (should (= (python-indent-calculate-indentation) 23))
424 (python-tests-look-at "type='toy',")
425 (should (eq (car (python-indent-context)) 'inside-paren
))
426 (should (= (python-indent-calculate-indentation) 27))
427 (python-tests-look-at "status='bought'")
428 (should (eq (car (python-indent-context)) 'inside-paren
))
429 (should (= (python-indent-calculate-indentation) 27))
430 (python-tests-look-at ") \\\\")
431 (should (eq (car (python-indent-context)) 'inside-paren
))
432 (should (= (python-indent-calculate-indentation) 23))
433 (python-tests-look-at ".aggregate(")
434 (should (eq (car (python-indent-context)) 'after-backslash
))
435 (should (= (python-indent-calculate-indentation) 23))
436 (python-tests-look-at "Sum('amount')")
437 (should (eq (car (python-indent-context)) 'inside-paren
))
438 (should (= (python-indent-calculate-indentation) 27))
439 (python-tests-look-at ") \\\\")
440 (should (eq (car (python-indent-context)) 'inside-paren
))
441 (should (= (python-indent-calculate-indentation) 23))
442 (python-tests-look-at ".values_list()")
443 (should (eq (car (python-indent-context)) 'after-backslash
))
444 (should (= (python-indent-calculate-indentation) 23))
446 (should (eq (car (python-indent-context)) 'after-line
))
447 (should (= (python-indent-calculate-indentation) 0))))
449 (ert-deftest python-indent-block-enders
()
450 "Test `python-indent-block-enders' value honoring."
451 (python-tests-with-temp-buffer
464 (python-tests-look-at "3)")
466 (= (python-indent-calculate-indentation) 12)
467 (python-tests-look-at "pass")
469 (= (python-indent-calculate-indentation) 8)))
474 (ert-deftest python-nav-beginning-of-defun-1
()
475 (python-tests-with-temp-buffer
477 def decoratorFunctionWithArguments(arg1, arg2, arg3):
478 '''print decorated function call data to stdout.
482 @decoratorFunctionWithArguments('arg1', 'arg2')
483 def func(a, b, c=True):
488 print 'Inside wwrap()'
489 def wrapped_f(*args):
490 print 'Inside wrapped_f()'
491 print 'Decorator arguments:', arg1, arg2, arg3
493 print 'After f(*args)'
497 (python-tests-look-at "return wrap")
498 (should (= (save-excursion
499 (python-nav-beginning-of-defun)
502 (python-tests-look-at "def wrapped_f(*args):" -
1)
505 (python-tests-look-at "def wrapped_f(*args):" -
1)
506 (should (= (save-excursion
507 (python-nav-beginning-of-defun)
510 (python-tests-look-at "def wwrap(f):" -
1)
513 (python-tests-look-at "def wwrap(f):" -
1)
514 (should (= (save-excursion
515 (python-nav-beginning-of-defun)
518 (python-tests-look-at "def decoratorFunctionWithArguments" -
1)
522 (ert-deftest python-nav-beginning-of-defun-2
()
523 (python-tests-with-temp-buffer
539 ;; Nested defuns, are handled with care.
540 (python-tests-look-at "def c(self):")
541 (should (= (save-excursion
542 (python-nav-beginning-of-defun)
545 (python-tests-look-at "def m(self):" -
1)
548 ;; Defuns on same levels should be respected.
549 (python-tests-look-at "def a():" -
1)
550 (should (= (save-excursion
551 (python-nav-beginning-of-defun)
554 (python-tests-look-at "def b():" -
1)
557 ;; Jump to a top level defun.
558 (python-tests-look-at "def b():" -
1)
559 (should (= (save-excursion
560 (python-nav-beginning-of-defun)
563 (python-tests-look-at "def m(self):" -
1)
566 ;; Jump to a top level defun again.
567 (python-tests-look-at "def m(self):" -
1)
568 (should (= (save-excursion
569 (python-nav-beginning-of-defun)
572 (python-tests-look-at "class C(object):" -
1)
576 (ert-deftest python-nav-end-of-defun-1
()
577 (python-tests-with-temp-buffer
593 (should (= (save-excursion
594 (python-tests-look-at "class C(object):")
595 (python-nav-end-of-defun)
599 (should (= (save-excursion
600 (python-tests-look-at "def m(self):")
601 (python-nav-end-of-defun)
604 (python-tests-look-at "def c(self):")
607 (should (= (save-excursion
608 (python-tests-look-at "def b():")
609 (python-nav-end-of-defun)
612 (python-tests-look-at "def b():")
615 (should (= (save-excursion
616 (python-tests-look-at "def c(self):")
617 (python-nav-end-of-defun)
622 (ert-deftest python-nav-end-of-defun-2
()
623 (python-tests-with-temp-buffer
625 def decoratorFunctionWithArguments(arg1, arg2, arg3):
626 '''print decorated function call data to stdout.
630 @decoratorFunctionWithArguments('arg1', 'arg2')
631 def func(a, b, c=True):
636 print 'Inside wwrap()'
637 def wrapped_f(*args):
638 print 'Inside wrapped_f()'
639 print 'Decorator arguments:', arg1, arg2, arg3
641 print 'After f(*args)'
645 (should (= (save-excursion
646 (python-tests-look-at "def decoratorFunctionWithArguments")
647 (python-nav-end-of-defun)
651 (should (= (save-excursion
652 (python-tests-look-at "@decoratorFunctionWithArguments")
653 (python-nav-end-of-defun)
657 (should (= (save-excursion
658 (python-tests-look-at "def wwrap(f):")
659 (python-nav-end-of-defun)
662 (python-tests-look-at "return wwrap")
663 (line-beginning-position))))
664 (should (= (save-excursion
665 (python-tests-look-at "def wrapped_f(*args):")
666 (python-nav-end-of-defun)
669 (python-tests-look-at "return wrapped_f")
670 (line-beginning-position))))
671 (should (= (save-excursion
672 (python-tests-look-at "f(*args)")
673 (python-nav-end-of-defun)
676 (python-tests-look-at "return wrapped_f")
677 (line-beginning-position))))))
679 (ert-deftest python-nav-backward-defun-1
()
680 (python-tests-with-temp-buffer
706 (goto-char (point-max))
707 (should (= (save-excursion (python-nav-backward-defun))
708 (python-tests-look-at " def c(self): # c" -
1)))
709 (should (= (save-excursion (python-nav-backward-defun))
710 (python-tests-look-at " def d(self): # d" -
1)))
711 (should (= (save-excursion (python-nav-backward-defun))
712 (python-tests-look-at " class C(object): # C" -
1)))
713 (should (= (save-excursion (python-nav-backward-defun))
714 (python-tests-look-at " class B(object): # B" -
1)))
715 (should (= (save-excursion (python-nav-backward-defun))
716 (python-tests-look-at " def b(self): # b" -
1)))
717 (should (= (save-excursion (python-nav-backward-defun))
718 (python-tests-look-at " def a(self): # a" -
1)))
719 (should (= (save-excursion (python-nav-backward-defun))
720 (python-tests-look-at "class A(object): # A" -
1)))
721 (should (not (python-nav-backward-defun)))))
723 (ert-deftest python-nav-backward-defun-2
()
724 (python-tests-with-temp-buffer
726 def decoratorFunctionWithArguments(arg1, arg2, arg3):
727 '''print decorated function call data to stdout.
731 @decoratorFunctionWithArguments('arg1', 'arg2')
732 def func(a, b, c=True):
737 print 'Inside wwrap()'
738 def wrapped_f(*args):
739 print 'Inside wrapped_f()'
740 print 'Decorator arguments:', arg1, arg2, arg3
742 print 'After f(*args)'
746 (goto-char (point-max))
747 (should (= (save-excursion (python-nav-backward-defun))
748 (python-tests-look-at " def wrapped_f(*args):" -
1)))
749 (should (= (save-excursion (python-nav-backward-defun))
750 (python-tests-look-at " def wwrap(f):" -
1)))
751 (should (= (save-excursion (python-nav-backward-defun))
752 (python-tests-look-at "def decoratorFunctionWithArguments(arg1, arg2, arg3):" -
1)))
753 (should (not (python-nav-backward-defun)))))
755 (ert-deftest python-nav-backward-defun-3
()
756 (python-tests-with-temp-buffer
772 (goto-char (point-min))
773 (let ((point (python-tests-look-at "class A(object):")))
774 (should (not (python-nav-backward-defun)))
775 (should (= point
(point))))))
777 (ert-deftest python-nav-forward-defun-1
()
778 (python-tests-with-temp-buffer
804 (goto-char (point-min))
805 (should (= (save-excursion (python-nav-forward-defun))
806 (python-tests-look-at "(object): # A")))
807 (should (= (save-excursion (python-nav-forward-defun))
808 (python-tests-look-at "(self): # a")))
809 (should (= (save-excursion (python-nav-forward-defun))
810 (python-tests-look-at "(self): # b")))
811 (should (= (save-excursion (python-nav-forward-defun))
812 (python-tests-look-at "(object): # B")))
813 (should (= (save-excursion (python-nav-forward-defun))
814 (python-tests-look-at "(object): # C")))
815 (should (= (save-excursion (python-nav-forward-defun))
816 (python-tests-look-at "(self): # d")))
817 (should (= (save-excursion (python-nav-forward-defun))
818 (python-tests-look-at "(self): # c")))
819 (should (not (python-nav-forward-defun)))))
821 (ert-deftest python-nav-forward-defun-2
()
822 (python-tests-with-temp-buffer
824 def decoratorFunctionWithArguments(arg1, arg2, arg3):
825 '''print decorated function call data to stdout.
829 @decoratorFunctionWithArguments('arg1', 'arg2')
830 def func(a, b, c=True):
835 print 'Inside wwrap()'
836 def wrapped_f(*args):
837 print 'Inside wrapped_f()'
838 print 'Decorator arguments:', arg1, arg2, arg3
840 print 'After f(*args)'
844 (goto-char (point-min))
845 (should (= (save-excursion (python-nav-forward-defun))
846 (python-tests-look-at "(arg1, arg2, arg3):")))
847 (should (= (save-excursion (python-nav-forward-defun))
848 (python-tests-look-at "(f):")))
849 (should (= (save-excursion (python-nav-forward-defun))
850 (python-tests-look-at "(*args):")))
851 (should (not (python-nav-forward-defun)))))
853 (ert-deftest python-nav-forward-defun-3
()
854 (python-tests-with-temp-buffer
870 (goto-char (point-min))
871 (let ((point (python-tests-look-at "(object):")))
872 (should (not (python-nav-forward-defun)))
873 (should (= point
(point))))))
875 (ert-deftest python-nav-beginning-of-statement-1
()
876 (python-tests-with-temp-buffer
886 v3 = ('this is a string'
891 # this is a comment, yo
892 'continue previous line')
898 (python-tests-look-at "v2 =")
899 (python-util-forward-comment -
1)
900 (should (= (save-excursion
901 (python-nav-beginning-of-statement)
903 (python-tests-look-at "v1 =" -
1 t
)))
904 (python-tests-look-at "v3 =")
905 (python-util-forward-comment -
1)
906 (should (= (save-excursion
907 (python-nav-beginning-of-statement)
909 (python-tests-look-at "v2 =" -
1 t
)))
910 (python-tests-look-at "v4 =")
911 (python-util-forward-comment -
1)
912 (should (= (save-excursion
913 (python-nav-beginning-of-statement)
915 (python-tests-look-at "v3 =" -
1 t
)))
916 (goto-char (point-max))
917 (python-util-forward-comment -
1)
918 (should (= (save-excursion
919 (python-nav-beginning-of-statement)
921 (python-tests-look-at "v4 =" -
1 t
)))))
923 (ert-deftest python-nav-end-of-statement-1
()
924 (python-tests-with-temp-buffer
934 v3 = ('this is a string'
939 # this is a comment, yo
940 'continue previous line')
946 (python-tests-look-at "v1 =")
947 (should (= (save-excursion
948 (python-nav-end-of-statement)
951 (python-tests-look-at "789")
952 (line-end-position))))
953 (python-tests-look-at "v2 =")
954 (should (= (save-excursion
955 (python-nav-end-of-statement)
958 (python-tests-look-at "value4)")
959 (line-end-position))))
960 (python-tests-look-at "v3 =")
961 (should (= (save-excursion
962 (python-nav-end-of-statement)
965 (python-tests-look-at
966 "'continue previous line')")
967 (line-end-position))))
968 (python-tests-look-at "v4 =")
969 (should (= (save-excursion
970 (python-nav-end-of-statement)
973 (goto-char (point-max))
974 (python-util-forward-comment -
1)
977 (ert-deftest python-nav-forward-statement-1
()
978 (python-tests-with-temp-buffer
988 v3 = ('this is a string'
993 # this is a comment, yo
994 'continue previous line')
1000 (python-tests-look-at "v1 =")
1001 (should (= (save-excursion
1002 (python-nav-forward-statement)
1004 (python-tests-look-at "v2 =")))
1005 (should (= (save-excursion
1006 (python-nav-forward-statement)
1008 (python-tests-look-at "v3 =")))
1009 (should (= (save-excursion
1010 (python-nav-forward-statement)
1012 (python-tests-look-at "v4 =")))
1013 (should (= (save-excursion
1014 (python-nav-forward-statement)
1018 (ert-deftest python-nav-backward-statement-1
()
1019 (python-tests-with-temp-buffer
1029 v3 = ('this is a string'
1034 # this is a comment, yo
1035 'continue previous line')
1041 (goto-char (point-max))
1042 (should (= (save-excursion
1043 (python-nav-backward-statement)
1045 (python-tests-look-at "v4 =" -
1)))
1046 (should (= (save-excursion
1047 (python-nav-backward-statement)
1049 (python-tests-look-at "v3 =" -
1)))
1050 (should (= (save-excursion
1051 (python-nav-backward-statement)
1053 (python-tests-look-at "v2 =" -
1)))
1054 (should (= (save-excursion
1055 (python-nav-backward-statement)
1057 (python-tests-look-at "v1 =" -
1)))))
1059 (ert-deftest python-nav-backward-statement-2
()
1060 :expected-result
:failed
1061 (python-tests-with-temp-buffer
1072 ;; FIXME: For some reason `python-nav-backward-statement' is moving
1073 ;; back two sentences when starting from 'value4)'.
1074 (goto-char (point-max))
1075 (python-util-forward-comment -
1)
1076 (should (= (save-excursion
1077 (python-nav-backward-statement)
1079 (python-tests-look-at "v2 =" -
1 t
)))))
1081 (ert-deftest python-nav-beginning-of-block-1
()
1082 (python-tests-with-temp-buffer
1084 def decoratorFunctionWithArguments(arg1, arg2, arg3):
1085 '''print decorated function call data to stdout.
1089 @decoratorFunctionWithArguments('arg1', 'arg2')
1090 def func(a, b, c=True):
1095 print 'Inside wwrap()'
1096 def wrapped_f(*args):
1097 print 'Inside wrapped_f()'
1098 print 'Decorator arguments:', arg1, arg2, arg3
1100 print 'After f(*args)'
1104 (python-tests-look-at "return wwrap")
1105 (should (= (save-excursion
1106 (python-nav-beginning-of-block)
1108 (python-tests-look-at "def decoratorFunctionWithArguments" -
1)))
1109 (python-tests-look-at "print 'Inside wwrap()'")
1110 (should (= (save-excursion
1111 (python-nav-beginning-of-block)
1113 (python-tests-look-at "def wwrap(f):" -
1)))
1114 (python-tests-look-at "print 'After f(*args)'")
1116 (should (= (save-excursion
1117 (python-nav-beginning-of-block)
1119 (python-tests-look-at "def wrapped_f(*args):" -
1)))
1120 (python-tests-look-at "return wrapped_f")
1121 (should (= (save-excursion
1122 (python-nav-beginning-of-block)
1124 (python-tests-look-at "def wwrap(f):" -
1)))))
1126 (ert-deftest python-nav-end-of-block-1
()
1127 (python-tests-with-temp-buffer
1129 def decoratorFunctionWithArguments(arg1, arg2, arg3):
1130 '''print decorated function call data to stdout.
1134 @decoratorFunctionWithArguments('arg1', 'arg2')
1135 def func(a, b, c=True):
1140 print 'Inside wwrap()'
1141 def wrapped_f(*args):
1142 print 'Inside wrapped_f()'
1143 print 'Decorator arguments:', arg1, arg2, arg3
1145 print 'After f(*args)'
1149 (python-tests-look-at "def decoratorFunctionWithArguments")
1150 (should (= (save-excursion
1151 (python-nav-end-of-block)
1154 (goto-char (point-max))
1155 (python-util-forward-comment -
1)
1157 (python-tests-look-at "def wwrap(f):")
1158 (should (= (save-excursion
1159 (python-nav-end-of-block)
1162 (python-tests-look-at "return wrapped_f")
1163 (line-end-position))))
1165 (should (= (save-excursion
1166 (python-nav-end-of-block)
1169 (python-tests-look-at "return wrapped_f")
1170 (line-end-position))))
1171 (python-tests-look-at "f(*args)")
1172 (should (= (save-excursion
1173 (python-nav-end-of-block)
1176 (python-tests-look-at "print 'After f(*args)'")
1177 (line-end-position))))))
1179 (ert-deftest python-nav-forward-block-1
()
1180 "This also accounts as a test for `python-nav-backward-block'."
1181 (python-tests-with-temp-buffer
1183 if request.user.is_authenticated():
1187 profile = request.user.get_profile()
1188 except Profile.DoesNotExist:
1189 profile = Profile.objects.create(user=request.user)
1192 profile.recalculate_stats()
1194 profile.clear_stats()
1199 (should (= (save-excursion (python-nav-forward-block))
1200 (python-tests-look-at "if request.user.is_authenticated():")))
1201 (should (= (save-excursion (python-nav-forward-block))
1202 (python-tests-look-at "try:")))
1203 (should (= (save-excursion (python-nav-forward-block))
1204 (python-tests-look-at "except Profile.DoesNotExist:")))
1205 (should (= (save-excursion (python-nav-forward-block))
1206 (python-tests-look-at "else:")))
1207 (should (= (save-excursion (python-nav-forward-block))
1208 (python-tests-look-at "if profile.stats:")))
1209 (should (= (save-excursion (python-nav-forward-block))
1210 (python-tests-look-at "else:")))
1211 (should (= (save-excursion (python-nav-forward-block))
1212 (python-tests-look-at "finally:")))
1213 ;; When point is at the last block, leave it there and return nil
1214 (should (not (save-excursion (python-nav-forward-block))))
1215 ;; Move backwards, and even if the number of moves is less than the
1216 ;; provided argument return the point.
1217 (should (= (save-excursion (python-nav-forward-block -
10))
1218 (python-tests-look-at
1219 "if request.user.is_authenticated():" -
1)))))
1221 (ert-deftest python-nav-lisp-forward-sexp-safe-1
()
1222 (python-tests-with-temp-buffer
1224 profile = Profile.objects.create(user=request.user)
1227 (python-tests-look-at "profile =")
1228 (python-nav-lisp-forward-sexp-safe 4)
1229 (should (looking-at "(user=request.user)"))
1230 (python-tests-look-at "user=request.user")
1231 (python-nav-lisp-forward-sexp-safe -
1)
1232 (should (looking-at "(user=request.user)"))
1233 (python-nav-lisp-forward-sexp-safe -
4)
1234 (should (looking-at "profile ="))
1235 (python-tests-look-at "user=request.user")
1236 (python-nav-lisp-forward-sexp-safe 3)
1237 (should (looking-at ")"))
1238 (python-nav-lisp-forward-sexp-safe 1)
1239 (should (looking-at "$"))
1240 (python-nav-lisp-forward-sexp-safe 1)
1241 (should (looking-at ".notify()"))))
1243 (ert-deftest python-nav-forward-sexp-1
()
1244 (python-tests-with-temp-buffer
1250 (python-tests-look-at "a()")
1251 (python-nav-forward-sexp)
1252 (should (looking-at "$"))
1253 (should (save-excursion
1255 (looking-at "a()")))
1256 (python-nav-forward-sexp)
1257 (should (looking-at "$"))
1258 (should (save-excursion
1260 (looking-at "b()")))
1261 (python-nav-forward-sexp)
1262 (should (looking-at "$"))
1263 (should (save-excursion
1265 (looking-at "c()")))
1266 ;; Movement next to a paren should do what lisp does and
1267 ;; unfortunately It can't change, because otherwise
1268 ;; `blink-matching-open' breaks.
1269 (python-nav-forward-sexp -
1)
1270 (should (looking-at "()"))
1271 (should (save-excursion
1273 (looking-at "c()")))
1274 (python-nav-forward-sexp -
1)
1275 (should (looking-at "c()"))
1276 (python-nav-forward-sexp -
1)
1277 (should (looking-at "b()"))
1278 (python-nav-forward-sexp -
1)
1279 (should (looking-at "a()"))))
1281 (ert-deftest python-nav-forward-sexp-2
()
1282 (python-tests-with-temp-buffer
1291 (python-tests-look-at "aa =")
1292 (python-nav-forward-sexp)
1293 (should (looking-at " = bbb"))
1294 (python-nav-forward-sexp)
1295 (should (looking-at "$"))
1296 (should (save-excursion
1297 (back-to-indentation)
1298 (looking-at "aaa = bbb")))
1299 (python-nav-forward-sexp)
1300 (should (looking-at "$"))
1301 (should (save-excursion
1302 (back-to-indentation)
1303 (looking-at "ccc = ddd")))
1304 (python-nav-forward-sexp)
1305 (should (looking-at "$"))
1306 (should (save-excursion
1307 (back-to-indentation)
1308 (looking-at "eee = fff")))
1309 (python-nav-forward-sexp)
1310 (should (looking-at "$"))
1311 (should (save-excursion
1312 (back-to-indentation)
1313 (looking-at "return ggg")))
1314 (python-nav-forward-sexp -
1)
1315 (should (looking-at "def func():"))))
1317 (ert-deftest python-nav-forward-sexp-3
()
1318 (python-tests-with-temp-buffer
1320 from some_module import some_sub_module
1321 from another_module import another_sub_module
1323 def another_statement():
1326 (python-tests-look-at "some_module")
1327 (python-nav-forward-sexp)
1328 (should (looking-at " import"))
1329 (python-nav-forward-sexp)
1330 (should (looking-at " some_sub_module"))
1331 (python-nav-forward-sexp)
1332 (should (looking-at "$"))
1335 (back-to-indentation)
1337 "from some_module import some_sub_module")))
1338 (python-nav-forward-sexp)
1339 (should (looking-at "$"))
1342 (back-to-indentation)
1344 "from another_module import another_sub_module")))
1345 (python-nav-forward-sexp)
1346 (should (looking-at "$"))
1349 (back-to-indentation)
1352 (python-nav-forward-sexp -
1)
1353 (should (looking-at "def another_statement():"))
1354 (python-nav-forward-sexp -
1)
1355 (should (looking-at "from another_module import another_sub_module"))
1356 (python-nav-forward-sexp -
1)
1357 (should (looking-at "from some_module import some_sub_module"))))
1359 (ert-deftest python-nav-up-list-1
()
1360 (python-tests-with-temp-buffer
1364 return [i for i in range(3)]
1366 (python-tests-look-at "3)]")
1367 (python-nav-up-list)
1368 (should (looking-at "]"))
1369 (python-nav-up-list)
1370 (should (looking-at "$"))))
1372 (ert-deftest python-nav-backward-up-list-1
()
1373 :expected-result
:failed
1374 (python-tests-with-temp-buffer
1378 return [i for i in range(3)]
1380 (python-tests-look-at "3)]")
1381 (python-nav-backward-up-list)
1382 (should (looking-at "(3)\\]"))
1383 (python-nav-backward-up-list)
1385 "\\[i for i in range(3)\\]"))
1386 ;; FIXME: Need to move to beginning-of-statement.
1387 (python-nav-backward-up-list)
1389 "return \\[i for i in range(3)\\]"))
1390 (python-nav-backward-up-list)
1391 (should (looking-at "if True:"))
1392 (python-nav-backward-up-list)
1393 (should (looking-at "def f():"))))
1396 ;;; Shell integration
1398 (defvar python-tests-shell-interpreter
"python")
1400 (ert-deftest python-shell-get-process-name-1
()
1401 "Check process name calculation on different scenarios."
1402 (python-tests-with-temp-buffer
1404 (should (string= (python-shell-get-process-name nil
)
1405 python-shell-buffer-name
))
1406 ;; When the `current-buffer' doesn't have `buffer-file-name', even
1407 ;; if dedicated flag is non-nil should not include its name.
1408 (should (string= (python-shell-get-process-name t
)
1409 python-shell-buffer-name
)))
1410 (python-tests-with-temp-file
1412 ;; `buffer-file-name' is non-nil but the dedicated flag is nil and
1413 ;; should be respected.
1414 (should (string= (python-shell-get-process-name nil
)
1415 python-shell-buffer-name
))
1417 (python-shell-get-process-name t
)
1418 (format "%s[%s]" python-shell-buffer-name buffer-file-name
)))))
1420 (ert-deftest python-shell-internal-get-process-name-1
()
1421 "Check the internal process name is config-unique."
1422 (let* ((python-shell-interpreter python-tests-shell-interpreter
)
1423 (python-shell-interpreter-args "")
1424 (python-shell-prompt-regexp ">>> ")
1425 (python-shell-prompt-block-regexp "[.][.][.] ")
1426 (python-shell-setup-codes "")
1427 (python-shell-process-environment "")
1428 (python-shell-extra-pythonpaths "")
1429 (python-shell-exec-path "")
1430 (python-shell-virtualenv-path "")
1431 (expected (python-tests-with-temp-buffer
1432 "" (python-shell-internal-get-process-name))))
1433 ;; Same configurations should match.
1436 (python-tests-with-temp-buffer
1437 "" (python-shell-internal-get-process-name))))
1438 (let ((python-shell-interpreter-args "-B"))
1439 ;; A minimal change should generate different names.
1443 (python-tests-with-temp-buffer
1444 "" (python-shell-internal-get-process-name))))))))
1446 (ert-deftest python-shell-parse-command-1
()
1447 "Check the command to execute is calculated correctly.
1448 Using `python-shell-interpreter' and
1449 `python-shell-interpreter-args'."
1450 :expected-result
(if (executable-find python-tests-shell-interpreter
)
1453 (let ((python-shell-interpreter (executable-find
1454 python-tests-shell-interpreter
))
1455 (python-shell-interpreter-args "-B"))
1458 python-shell-interpreter
1459 python-shell-interpreter-args
)
1460 (python-shell-parse-command)))))
1462 (ert-deftest python-shell-calculate-process-environment-1
()
1463 "Test `python-shell-process-environment' modification."
1464 (let* ((original-process-environment process-environment
)
1465 (python-shell-process-environment
1466 '("TESTVAR1=value1" "TESTVAR2=value2"))
1467 (process-environment
1468 (python-shell-calculate-process-environment)))
1469 (should (equal (getenv "TESTVAR1") "value1"))
1470 (should (equal (getenv "TESTVAR2") "value2"))))
1472 (ert-deftest python-shell-calculate-process-environment-2
()
1473 "Test `python-shell-extra-pythonpaths' modification."
1474 (let* ((original-process-environment process-environment
)
1475 (original-pythonpath (getenv "PYTHONPATH"))
1476 (paths '("path1" "path2"))
1477 (python-shell-extra-pythonpaths paths
)
1478 (process-environment
1479 (python-shell-calculate-process-environment)))
1480 (should (equal (getenv "PYTHONPATH")
1482 (mapconcat 'identity paths path-separator
)
1483 path-separator original-pythonpath
)))))
1485 (ert-deftest python-shell-calculate-process-environment-3
()
1486 "Test `python-shell-virtualenv-path' modification."
1487 (let* ((original-process-environment process-environment
)
1488 (original-path (or (getenv "PATH") ""))
1489 (python-shell-virtualenv-path
1490 (directory-file-name user-emacs-directory
))
1491 (process-environment
1492 (python-shell-calculate-process-environment)))
1493 (should (not (getenv "PYTHONHOME")))
1494 (should (string= (getenv "VIRTUAL_ENV") python-shell-virtualenv-path
))
1495 (should (equal (getenv "PATH")
1496 (format "%s/bin%s%s"
1497 python-shell-virtualenv-path
1498 path-separator original-path
)))))
1500 (ert-deftest python-shell-calculate-exec-path-1
()
1501 "Test `python-shell-exec-path' modification."
1502 (let* ((original-exec-path exec-path
)
1503 (python-shell-exec-path '("path1" "path2"))
1504 (exec-path (python-shell-calculate-exec-path)))
1507 (append python-shell-exec-path
1508 original-exec-path
)))))
1510 (ert-deftest python-shell-calculate-exec-path-2
()
1511 "Test `python-shell-exec-path' modification."
1512 (let* ((original-exec-path exec-path
)
1513 (python-shell-virtualenv-path
1514 (directory-file-name user-emacs-directory
))
1515 (exec-path (python-shell-calculate-exec-path)))
1519 (format "%s/bin" python-shell-virtualenv-path
)
1520 original-exec-path
))))))
1522 (ert-deftest python-shell-make-comint-1
()
1523 "Check comint creation for global shell buffer."
1524 :expected-result
(if (executable-find python-tests-shell-interpreter
)
1527 (let* ((python-shell-interpreter
1528 (executable-find python-tests-shell-interpreter
))
1529 (proc-name (python-shell-get-process-name nil
))
1531 (python-tests-with-temp-buffer
1532 "" (python-shell-make-comint
1533 (python-shell-parse-command) proc-name
)))
1534 (process (get-buffer-process shell-buffer
)))
1537 (set-process-query-on-exit-flag process nil
)
1538 (should (process-live-p process
))
1539 (with-current-buffer shell-buffer
1540 (should (eq major-mode
'inferior-python-mode
))
1541 (should (string= (buffer-name) (format "*%s*" proc-name
)))))
1542 (kill-buffer shell-buffer
))))
1544 (ert-deftest python-shell-make-comint-2
()
1545 "Check comint creation for internal shell buffer."
1546 :expected-result
(if (executable-find python-tests-shell-interpreter
)
1549 (let* ((python-shell-interpreter
1550 (executable-find python-tests-shell-interpreter
))
1551 (proc-name (python-shell-internal-get-process-name))
1553 (python-tests-with-temp-buffer
1554 "" (python-shell-make-comint
1555 (python-shell-parse-command) proc-name nil t
)))
1556 (process (get-buffer-process shell-buffer
)))
1559 (set-process-query-on-exit-flag process nil
)
1560 (should (process-live-p process
))
1561 (with-current-buffer shell-buffer
1562 (should (eq major-mode
'inferior-python-mode
))
1563 (should (string= (buffer-name) (format " *%s*" proc-name
)))))
1564 (kill-buffer shell-buffer
))))
1566 (ert-deftest python-shell-get-process-1
()
1567 "Check dedicated shell process preference over global."
1568 :expected-result
(if (executable-find python-tests-shell-interpreter
)
1571 (python-tests-with-temp-file
1573 (let* ((python-shell-interpreter
1574 (executable-find python-tests-shell-interpreter
))
1575 (global-proc-name (python-shell-get-process-name nil
))
1576 (dedicated-proc-name (python-shell-get-process-name t
))
1577 (global-shell-buffer
1578 (python-shell-make-comint
1579 (python-shell-parse-command) global-proc-name
))
1580 (dedicated-shell-buffer
1581 (python-shell-make-comint
1582 (python-shell-parse-command) dedicated-proc-name
))
1583 (global-process (get-buffer-process global-shell-buffer
))
1584 (dedicated-process (get-buffer-process dedicated-shell-buffer
)))
1587 (set-process-query-on-exit-flag global-process nil
)
1588 (set-process-query-on-exit-flag dedicated-process nil
)
1589 ;; Prefer dedicated if global also exists.
1590 (should (equal (python-shell-get-process) dedicated-process
))
1591 (kill-buffer dedicated-shell-buffer
)
1592 ;; If there's only global, use it.
1593 (should (equal (python-shell-get-process) global-process
))
1594 (kill-buffer global-shell-buffer
)
1595 ;; No buffer available.
1596 (should (not (python-shell-get-process))))
1597 (ignore-errors (kill-buffer global-shell-buffer
))
1598 (ignore-errors (kill-buffer dedicated-shell-buffer
))))))
1600 (ert-deftest python-shell-get-or-create-process-1
()
1601 "Check shell process creation fallback."
1602 :expected-result
:failed
1603 (python-tests-with-temp-file
1605 ;; XXX: Break early until we can skip stuff. We need to mimic
1606 ;; user interaction because `python-shell-get-or-create-process'
1607 ;; asks for all arguments interactively when a shell process
1610 (let* ((python-shell-interpreter
1611 (executable-find python-tests-shell-interpreter
))
1613 (dedicated-process-name (python-shell-get-process-name t
))
1614 (dedicated-process (python-shell-get-or-create-process))
1615 (dedicated-shell-buffer (process-buffer dedicated-process
)))
1618 (set-process-query-on-exit-flag dedicated-process nil
)
1619 ;; Prefer dedicated if not buffer exist.
1620 (should (equal (process-name dedicated-process
)
1621 dedicated-process-name
))
1622 (kill-buffer dedicated-shell-buffer
)
1623 ;; No buffer available.
1624 (should (not (python-shell-get-process))))
1625 (ignore-errors (kill-buffer dedicated-shell-buffer
))))))
1627 (ert-deftest python-shell-internal-get-or-create-process-1
()
1628 "Check internal shell process creation fallback."
1629 :expected-result
(if (executable-find python-tests-shell-interpreter
)
1632 (python-tests-with-temp-file
1634 (should (not (process-live-p (python-shell-internal-get-process-name))))
1635 (let* ((python-shell-interpreter
1636 (executable-find python-tests-shell-interpreter
))
1637 (internal-process-name (python-shell-internal-get-process-name))
1638 (internal-process (python-shell-internal-get-or-create-process))
1639 (internal-shell-buffer (process-buffer internal-process
)))
1642 (set-process-query-on-exit-flag internal-process nil
)
1643 (should (equal (process-name internal-process
)
1644 internal-process-name
))
1645 (should (equal internal-process
1646 (python-shell-internal-get-or-create-process)))
1647 ;; No user buffer available.
1648 (should (not (python-shell-get-process)))
1649 (kill-buffer internal-shell-buffer
))
1650 (ignore-errors (kill-buffer internal-shell-buffer
))))))
1653 ;;; Shell completion
1656 ;;; PDB Track integration
1659 ;;; Symbol completion
1679 (ert-deftest python-imenu-create-index-1
()
1680 (python-tests-with-temp-buffer
1682 class Foo(models.Model):
1686 class Bar(models.Model):
1690 def decorator(arg1, arg2, arg3):
1691 '''print decorated function call data to stdout.
1695 @decorator('arg1', 'arg2')
1696 def func(a, b, c=True):
1702 def wrapped_f(*args):
1704 print ('Decorator arguments:', arg1, arg2, arg3)
1706 print ('called f(*args)')
1724 (goto-char (point-max))
1727 (cons "Foo (class)" (copy-marker 2))
1728 (cons "Bar (class)" (copy-marker 38))
1731 (cons "*function definition*" (copy-marker 74))
1734 (cons "*function definition*" (copy-marker 254))
1735 (cons "wrapped_f (def)" (copy-marker 294))))
1738 (cons "*class definition*" (copy-marker 519))
1739 (cons "a (def)" (copy-marker 539))
1740 (cons "b (def)" (copy-marker 570))
1743 (cons "*class definition*" (copy-marker 601))
1744 (cons "c (def)" (copy-marker 626)))))
1745 (python-imenu-create-index)))))
1747 (ert-deftest python-imenu-create-flat-index-1
()
1748 (python-tests-with-temp-buffer
1750 class Foo(models.Model):
1754 class Bar(models.Model):
1758 def decorator(arg1, arg2, arg3):
1759 '''print decorated function call data to stdout.
1763 @decorator('arg1', 'arg2')
1764 def func(a, b, c=True):
1770 def wrapped_f(*args):
1772 print ('Decorator arguments:', arg1, arg2, arg3)
1774 print ('called f(*args)')
1792 (goto-char (point-max))
1794 (list (cons "Foo" (copy-marker 2))
1795 (cons "Bar" (copy-marker 38))
1796 (cons "decorator" (copy-marker 74))
1797 (cons "decorator.wrap" (copy-marker 254))
1798 (cons "decorator.wrap.wrapped_f" (copy-marker 294))
1799 (cons "Baz" (copy-marker 519))
1800 (cons "Baz.a" (copy-marker 539))
1801 (cons "Baz.b" (copy-marker 570))
1802 (cons "Baz.Frob" (copy-marker 601))
1803 (cons "Baz.Frob.c" (copy-marker 626)))
1804 (python-imenu-create-flat-index)))))
1809 (ert-deftest python-info-current-defun-1
()
1810 (python-tests-with-temp-buffer
1815 (should (string= "foo" (python-info-current-defun)))
1816 (should (string= "def foo" (python-info-current-defun t)))
1818 (should (not (python-info-current-defun)))
1819 (indent-for-tab-command)
1820 (should (string= "foo" (python-info-current-defun)))
1821 (should (string= "def foo" (python-info-current-defun t)))))
1823 (ert-deftest python-info-current-defun-2
()
1824 (python-tests-with-temp-buffer
1830 return [i for i in range(3)]
1844 (should (string= "C" (python-info-current-defun)))
1845 (should (string= "class C" (python-info-current-defun t)))
1846 (python-tests-look-at "return [i for ")
1847 (should (string= "C.m" (python-info-current-defun)))
1848 (should (string= "def C.m" (python-info-current-defun t)))
1849 (python-tests-look-at "def b():")
1850 (should (string= "C.m.b" (python-info-current-defun)))
1851 (should (string= "def C.m.b" (python-info-current-defun t)))
1853 (indent-for-tab-command)
1854 (python-indent-dedent-line-backspace 1)
1855 (should (string= "C.m" (python-info-current-defun)))
1856 (should (string= "def C.m" (python-info-current-defun t)))
1857 (python-tests-look-at "def c(self):")
1859 (indent-for-tab-command)
1860 (should (string= "C.m.a" (python-info-current-defun)))
1861 (should (string= "def C.m.a" (python-info-current-defun t)))
1862 (python-indent-dedent-line-backspace 1)
1863 (should (string= "C.m" (python-info-current-defun)))
1864 (should (string= "def C.m" (python-info-current-defun t)))
1865 (python-indent-dedent-line-backspace 1)
1866 (should (string= "C" (python-info-current-defun)))
1867 (should (string= "class C" (python-info-current-defun t)))
1868 (python-tests-look-at "def c(self):")
1869 (should (string= "C.c" (python-info-current-defun)))
1870 (should (string= "def C.c" (python-info-current-defun t)))
1871 (python-tests-look-at "do_c()")
1872 (should (string= "C.c" (python-info-current-defun)))
1873 (should (string= "def C.c" (python-info-current-defun t)))))
1875 (ert-deftest python-info-current-defun-3
()
1876 (python-tests-with-temp-buffer
1878 def decoratorFunctionWithArguments(arg1, arg2, arg3):
1879 '''print decorated function call data to stdout.
1883 @decoratorFunctionWithArguments('arg1', 'arg2')
1884 def func(a, b, c=True):
1889 print 'Inside wwrap()'
1890 def wrapped_f(*args):
1891 print 'Inside wrapped_f()'
1892 print 'Decorator arguments:', arg1, arg2, arg3
1894 print 'After f(*args)'
1898 (python-tests-look-at "def wwrap(f):")
1900 (should (not (python-info-current-defun)))
1901 (indent-for-tab-command 1)
1902 (should (string= (python-info-current-defun)
1903 "decoratorFunctionWithArguments"))
1904 (should (string= (python-info-current-defun t)
1905 "def decoratorFunctionWithArguments"))
1906 (python-tests-look-at "def wrapped_f(*args):")
1907 (should (string= (python-info-current-defun)
1908 "decoratorFunctionWithArguments.wwrap.wrapped_f"))
1909 (should (string= (python-info-current-defun t)
1910 "def decoratorFunctionWithArguments.wwrap.wrapped_f"))
1911 (python-tests-look-at "return wrapped_f")
1912 (should (string= (python-info-current-defun)
1913 "decoratorFunctionWithArguments.wwrap"))
1914 (should (string= (python-info-current-defun t)
1915 "def decoratorFunctionWithArguments.wwrap"))
1917 (python-tests-look-at "return wwrap")
1918 (should (string= (python-info-current-defun)
1919 "decoratorFunctionWithArguments"))
1920 (should (string= (python-info-current-defun t)
1921 "def decoratorFunctionWithArguments"))))
1923 (ert-deftest python-info-current-symbol-1
()
1924 (python-tests-with-temp-buffer
1934 (python-tests-look-at "self.c()")
1935 (should (string= "self.c" (python-info-current-symbol)))
1936 (should (string= "C.c" (python-info-current-symbol t
)))))
1938 (ert-deftest python-info-current-symbol-2
()
1939 (python-tests-with-temp-buffer
1951 (python-tests-look-at "self.c()")
1952 (should (string= "self.c" (python-info-current-symbol)))
1953 (should (string= "C.M.c" (python-info-current-symbol t
)))))
1955 (ert-deftest python-info-current-symbol-3
()
1956 "Keywords should not be considered symbols."
1957 :expected-result
:failed
1958 (python-tests-with-temp-buffer
1963 ;; FIXME: keywords are not symbols.
1964 (python-tests-look-at "class C")
1965 (should (not (python-info-current-symbol)))
1966 (should (not (python-info-current-symbol t
)))
1967 (python-tests-look-at "C(object)")
1968 (should (string= "C" (python-info-current-symbol)))
1969 (should (string= "class C" (python-info-current-symbol t
)))))
1971 (ert-deftest python-info-statement-starts-block-p-1
()
1972 (python-tests-with-temp-buffer
1974 def long_function_name(
1975 var_one, var_two, var_three,
1979 (python-tests-look-at "def long_function_name")
1980 (should (python-info-statement-starts-block-p))
1981 (python-tests-look-at "print (var_one)")
1982 (python-util-forward-comment -
1)
1983 (should (python-info-statement-starts-block-p))))
1985 (ert-deftest python-info-statement-starts-block-p-2
()
1986 (python-tests-with-temp-buffer
1988 if width == 0 and height == 0 and \\\\
1989 color == 'red' and emphasis == 'strong' or \\\\
1991 raise ValueError('sorry, you lose')
1993 (python-tests-look-at "if width == 0 and")
1994 (should (python-info-statement-starts-block-p))
1995 (python-tests-look-at "raise ValueError(")
1996 (python-util-forward-comment -
1)
1997 (should (python-info-statement-starts-block-p))))
1999 (ert-deftest python-info-statement-ends-block-p-1
()
2000 (python-tests-with-temp-buffer
2002 def long_function_name(
2003 var_one, var_two, var_three,
2007 (python-tests-look-at "print (var_one)")
2008 (should (python-info-statement-ends-block-p))))
2010 (ert-deftest python-info-statement-ends-block-p-2
()
2011 (python-tests-with-temp-buffer
2013 if width == 0 and height == 0 and \\\\
2014 color == 'red' and emphasis == 'strong' or \\\\
2021 (python-tests-look-at "raise ValueError(")
2022 (should (python-info-statement-ends-block-p))))
2024 (ert-deftest python-info-beginning-of-statement-p-1
()
2025 (python-tests-with-temp-buffer
2027 def long_function_name(
2028 var_one, var_two, var_three,
2032 (python-tests-look-at "def long_function_name")
2033 (should (python-info-beginning-of-statement-p))
2035 (should (not (python-info-beginning-of-statement-p)))
2036 (python-tests-look-at "print (var_one)")
2037 (should (python-info-beginning-of-statement-p))
2038 (goto-char (line-beginning-position))
2039 (should (not (python-info-beginning-of-statement-p)))))
2041 (ert-deftest python-info-beginning-of-statement-p-2
()
2042 (python-tests-with-temp-buffer
2044 if width == 0 and height == 0 and \\\\
2045 color == 'red' and emphasis == 'strong' or \\\\
2052 (python-tests-look-at "if width == 0 and")
2053 (should (python-info-beginning-of-statement-p))
2055 (should (not (python-info-beginning-of-statement-p)))
2056 (python-tests-look-at "raise ValueError(")
2057 (should (python-info-beginning-of-statement-p))
2058 (goto-char (line-beginning-position))
2059 (should (not (python-info-beginning-of-statement-p)))))
2061 (ert-deftest python-info-end-of-statement-p-1
()
2062 (python-tests-with-temp-buffer
2064 def long_function_name(
2065 var_one, var_two, var_three,
2069 (python-tests-look-at "def long_function_name")
2070 (should (not (python-info-end-of-statement-p)))
2072 (should (not (python-info-end-of-statement-p)))
2073 (python-tests-look-at "print (var_one)")
2074 (python-util-forward-comment -
1)
2075 (should (python-info-end-of-statement-p))
2076 (python-tests-look-at "print (var_one)")
2077 (should (not (python-info-end-of-statement-p)))
2079 (should (python-info-end-of-statement-p))))
2081 (ert-deftest python-info-end-of-statement-p-2
()
2082 (python-tests-with-temp-buffer
2084 if width == 0 and height == 0 and \\\\
2085 color == 'red' and emphasis == 'strong' or \\\\
2092 (python-tests-look-at "if width == 0 and")
2093 (should (not (python-info-end-of-statement-p)))
2095 (should (not (python-info-end-of-statement-p)))
2096 (python-tests-look-at "raise ValueError(")
2097 (python-util-forward-comment -
1)
2098 (should (python-info-end-of-statement-p))
2099 (python-tests-look-at "raise ValueError(")
2100 (should (not (python-info-end-of-statement-p)))
2102 (should (not (python-info-end-of-statement-p)))
2103 (goto-char (point-max))
2104 (python-util-forward-comment -
1)
2105 (should (python-info-end-of-statement-p))))
2107 (ert-deftest python-info-beginning-of-block-p-1
()
2108 (python-tests-with-temp-buffer
2110 def long_function_name(
2111 var_one, var_two, var_three,
2115 (python-tests-look-at "def long_function_name")
2116 (should (python-info-beginning-of-block-p))
2117 (python-tests-look-at "var_one, var_two, var_three,")
2118 (should (not (python-info-beginning-of-block-p)))
2119 (python-tests-look-at "print (var_one)")
2120 (should (not (python-info-beginning-of-block-p)))))
2122 (ert-deftest python-info-beginning-of-block-p-2
()
2123 (python-tests-with-temp-buffer
2125 if width == 0 and height == 0 and \\\\
2126 color == 'red' and emphasis == 'strong' or \\\\
2133 (python-tests-look-at "if width == 0 and")
2134 (should (python-info-beginning-of-block-p))
2135 (python-tests-look-at "color == 'red' and emphasis")
2136 (should (not (python-info-beginning-of-block-p)))
2137 (python-tests-look-at "raise ValueError(")
2138 (should (not (python-info-beginning-of-block-p)))))
2140 (ert-deftest python-info-end-of-block-p-1
()
2141 (python-tests-with-temp-buffer
2143 def long_function_name(
2144 var_one, var_two, var_three,
2148 (python-tests-look-at "def long_function_name")
2149 (should (not (python-info-end-of-block-p)))
2150 (python-tests-look-at "var_one, var_two, var_three,")
2151 (should (not (python-info-end-of-block-p)))
2152 (python-tests-look-at "var_four):")
2154 (should (not (python-info-end-of-block-p)))
2155 (python-tests-look-at "print (var_one)")
2156 (should (not (python-info-end-of-block-p)))
2158 (should (python-info-end-of-block-p))))
2160 (ert-deftest python-info-end-of-block-p-2
()
2161 (python-tests-with-temp-buffer
2163 if width == 0 and height == 0 and \\\\
2164 color == 'red' and emphasis == 'strong' or \\\\
2171 (python-tests-look-at "if width == 0 and")
2172 (should (not (python-info-end-of-block-p)))
2173 (python-tests-look-at "color == 'red' and emphasis == 'strong' or")
2174 (should (not (python-info-end-of-block-p)))
2175 (python-tests-look-at "highlight > 100:")
2177 (should (not (python-info-end-of-block-p)))
2178 (python-tests-look-at "raise ValueError(")
2179 (should (not (python-info-end-of-block-p)))
2181 (should (not (python-info-end-of-block-p)))
2182 (goto-char (point-max))
2183 (python-util-forward-comment -
1)
2184 (should (python-info-end-of-block-p))))
2186 (ert-deftest python-info-closing-block-1
()
2187 (python-tests-with-temp-buffer
2189 if request.user.is_authenticated():
2191 profile = request.user.get_profile()
2192 except Profile.DoesNotExist:
2193 profile = Profile.objects.create(user=request.user)
2196 profile.recalculate_stats()
2198 profile.clear_stats()
2203 (python-tests-look-at "try:")
2204 (should (not (python-info-closing-block)))
2205 (python-tests-look-at "except Profile.DoesNotExist:")
2206 (should (= (python-tests-look-at "try:" -
1 t
)
2207 (python-info-closing-block)))
2208 (python-tests-look-at "else:")
2209 (should (= (python-tests-look-at "except Profile.DoesNotExist:" -
1 t
)
2210 (python-info-closing-block)))
2211 (python-tests-look-at "if profile.stats:")
2212 (should (not (python-info-closing-block)))
2213 (python-tests-look-at "else:")
2214 (should (= (python-tests-look-at "if profile.stats:" -
1 t
)
2215 (python-info-closing-block)))
2216 (python-tests-look-at "finally:")
2217 (should (= (python-tests-look-at "else:" -
2 t
)
2218 (python-info-closing-block)))))
2220 (ert-deftest python-info-closing-block-2
()
2221 (python-tests-with-temp-buffer
2223 if request.user.is_authenticated():
2224 profile = Profile.objects.get_or_create(user=request.user)
2226 profile.recalculate_stats()
2233 (python-tests-look-at "'else': 'do it'")
2234 (should (not (python-info-closing-block)))
2235 (python-tests-look-at "'else'")
2236 (should (not (python-info-closing-block)))))
2238 (ert-deftest python-info-line-ends-backslash-p-1
()
2239 (python-tests-with-temp-buffer
2241 objects = Thing.objects.all() \\\\
2251 (should (python-info-line-ends-backslash-p 2)) ; .filter(...
2252 (should (python-info-line-ends-backslash-p 3))
2253 (should (python-info-line-ends-backslash-p 4))
2254 (should (python-info-line-ends-backslash-p 5))
2255 (should (python-info-line-ends-backslash-p 6)) ; ) \...
2256 (should (python-info-line-ends-backslash-p 7))
2257 (should (python-info-line-ends-backslash-p 8))
2258 (should (python-info-line-ends-backslash-p 9))
2259 (should (not (python-info-line-ends-backslash-p 10))))) ; .values_list()...
2261 (ert-deftest python-info-beginning-of-backslash-1
()
2262 (python-tests-with-temp-buffer
2264 objects = Thing.objects.all() \\\\
2275 (second (python-tests-look-at ".filter("))
2276 (third (python-tests-look-at ".aggregate(")))
2277 (should (= first
(python-info-beginning-of-backslash 2)))
2278 (should (= second
(python-info-beginning-of-backslash 3)))
2279 (should (= second
(python-info-beginning-of-backslash 4)))
2280 (should (= second
(python-info-beginning-of-backslash 5)))
2281 (should (= second
(python-info-beginning-of-backslash 6)))
2282 (should (= third
(python-info-beginning-of-backslash 7)))
2283 (should (= third
(python-info-beginning-of-backslash 8)))
2284 (should (= third
(python-info-beginning-of-backslash 9)))
2285 (should (not (python-info-beginning-of-backslash 10))))))
2287 (ert-deftest python-info-continuation-line-p-1
()
2288 (python-tests-with-temp-buffer
2290 if width == 0 and height == 0 and \\\\
2291 color == 'red' and emphasis == 'strong' or \\\\
2298 (python-tests-look-at "if width == 0 and height == 0 and")
2299 (should (not (python-info-continuation-line-p)))
2300 (python-tests-look-at "color == 'red' and emphasis == 'strong' or")
2301 (should (python-info-continuation-line-p))
2302 (python-tests-look-at "highlight > 100:")
2303 (should (python-info-continuation-line-p))
2304 (python-tests-look-at "raise ValueError(")
2305 (should (not (python-info-continuation-line-p)))
2306 (python-tests-look-at "'sorry, you lose'")
2307 (should (python-info-continuation-line-p))
2309 (should (python-info-continuation-line-p))
2310 (python-tests-look-at ")")
2311 (should (python-info-continuation-line-p))
2313 (should (not (python-info-continuation-line-p)))))
2315 (ert-deftest python-info-block-continuation-line-p-1
()
2316 (python-tests-with-temp-buffer
2318 if width == 0 and height == 0 and \\\\
2319 color == 'red' and emphasis == 'strong' or \\\\
2326 (python-tests-look-at "if width == 0 and")
2327 (should (not (python-info-block-continuation-line-p)))
2328 (python-tests-look-at "color == 'red' and emphasis == 'strong' or")
2329 (should (= (python-info-block-continuation-line-p)
2330 (python-tests-look-at "if width == 0 and" -
1 t
)))
2331 (python-tests-look-at "highlight > 100:")
2332 (should (not (python-info-block-continuation-line-p)))))
2334 (ert-deftest python-info-block-continuation-line-p-2
()
2335 (python-tests-with-temp-buffer
2342 (python-tests-look-at "def foo(a,")
2343 (should (not (python-info-block-continuation-line-p)))
2344 (python-tests-look-at "b,")
2345 (should (= (python-info-block-continuation-line-p)
2346 (python-tests-look-at "def foo(a," -
1 t
)))
2347 (python-tests-look-at "c):")
2348 (should (not (python-info-block-continuation-line-p)))))
2350 (ert-deftest python-info-assignment-continuation-line-p-1
()
2351 (python-tests-with-temp-buffer
2353 data = foo(), bar() \\\\
2357 (python-tests-look-at "data = foo(), bar()")
2358 (should (not (python-info-assignment-continuation-line-p)))
2359 (python-tests-look-at "baz(), 4")
2360 (should (= (python-info-assignment-continuation-line-p)
2361 (python-tests-look-at "foo()," -
1 t
)))
2362 (python-tests-look-at "5, 6")
2363 (should (not (python-info-assignment-continuation-line-p)))))
2365 (ert-deftest python-info-assignment-continuation-line-p-2
()
2366 (python-tests-with-temp-buffer
2368 data = (foo(), bar()
2372 (python-tests-look-at "data = (foo(), bar()")
2373 (should (not (python-info-assignment-continuation-line-p)))
2374 (python-tests-look-at "baz(), 4")
2375 (should (= (python-info-assignment-continuation-line-p)
2376 (python-tests-look-at "(foo()," -
1 t
)))
2377 (python-tests-look-at "5, 6)")
2378 (should (not (python-info-assignment-continuation-line-p)))))
2380 (ert-deftest python-info-looking-at-beginning-of-defun-1
()
2381 (python-tests-with-temp-buffer
2383 def decorat0r(deff):
2394 (python-tests-look-at "def decorat0r(deff):")
2395 (should (python-info-looking-at-beginning-of-defun))
2396 (python-tests-look-at "def foo(arg):")
2397 (should (not (python-info-looking-at-beginning-of-defun)))
2398 (python-tests-look-at "def wrap():")
2399 (should (python-info-looking-at-beginning-of-defun))
2400 (python-tests-look-at "deff()")
2401 (should (not (python-info-looking-at-beginning-of-defun)))))
2403 (ert-deftest python-info-current-line-comment-p-1
()
2404 (python-tests-with-temp-buffer
2407 foo = True # another comment
2411 print ('bar') # print bar
2413 (python-tests-look-at "# this is a comment")
2414 (should (python-info-current-line-comment-p))
2415 (python-tests-look-at "foo = True # another comment")
2416 (should (not (python-info-current-line-comment-p)))
2417 (python-tests-look-at "'#this is a string'")
2418 (should (not (python-info-current-line-comment-p)))
2419 (python-tests-look-at "# more comments")
2420 (should (python-info-current-line-comment-p))
2421 (python-tests-look-at "print ('bar') # print bar")
2422 (should (not (python-info-current-line-comment-p)))))
2424 (ert-deftest python-info-current-line-empty-p
()
2425 (python-tests-with-temp-buffer
2429 foo = True # another comment
2431 (should (python-info-current-line-empty-p))
2432 (python-tests-look-at "# this is a comment")
2433 (should (not (python-info-current-line-empty-p)))
2435 (should (python-info-current-line-empty-p))))
2438 ;;; Utility functions
2440 (ert-deftest python-util-goto-line-1
()
2441 (python-tests-with-temp-buffer
2446 pass" (make-string 20 ?
\n))
2447 (python-util-goto-line 10)
2448 (should (= (line-number-at-pos) 10))
2449 (python-util-goto-line 20)
2450 (should (= (line-number-at-pos) 20))))
2452 (ert-deftest python-util-clone-local-variables-1
()
2453 (let ((buffer (generate-new-buffer
2454 "python-util-clone-local-variables-1"))
2456 '((python-fill-docstring-style . django
)
2457 (python-shell-interpreter .
"python")
2458 (python-shell-interpreter-args .
"manage.py shell")
2459 (python-shell-prompt-regexp .
"In \\[[0-9]+\\]: ")
2460 (python-shell-prompt-output-regexp .
"Out\\[[0-9]+\\]: ")
2461 (python-shell-extra-pythonpaths "/home/user/pylib/")
2462 (python-shell-completion-setup-code
2463 .
"from IPython.core.completerlib import module_completion")
2464 (python-shell-completion-module-string-code
2465 .
"';'.join(module_completion('''%s'''))\n")
2466 (python-shell-completion-string-code
2467 .
"';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
2468 (python-shell-virtualenv-path
2469 .
"/home/user/.virtualenvs/project"))))
2470 (with-current-buffer buffer
2471 (kill-all-local-variables)
2472 (dolist (ccons varcons
)
2473 (set (make-local-variable (car ccons
)) (cdr ccons
))))
2474 (python-tests-with-temp-buffer
2476 (python-util-clone-local-variables buffer
)
2477 (dolist (ccons varcons
)
2479 (equal (symbol-value (car ccons
)) (cdr ccons
)))))
2480 (kill-buffer buffer
)))
2482 (ert-deftest python-util-forward-comment-1
()
2483 (python-tests-with-temp-buffer
2487 # bad indented comment
2488 # more comments" (make-string 9999 ?
\n))
2489 (python-util-forward-comment 1)
2490 (should (= (point) (point-max)))
2491 (python-util-forward-comment -
1)
2492 (should (= (point) (point-min)))))
2495 (provide 'python-tests
)
2499 ;; indent-tabs-mode: nil
2502 ;;; python-tests.el ends here