aboutsummaryrefslogtreecommitdiffstats
path: root/test/automated/python-tests.el
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2014-12-27 13:31:20 -0300
committerFabián Ezequiel Gallina2014-12-27 13:31:20 -0300
commit35e1f9d9fcbaab51808e05f514e63927f959ae51 (patch)
treee9d7d0ef8b1d61d728d4d076e46088a3b9b29d73 /test/automated/python-tests.el
parentf315b69922db769f3358e15616aa76c965be8a89 (diff)
parenta5f38fa1cc8eafe13f2073ebfaa8205b5e919d17 (diff)
downloademacs-35e1f9d9fcbaab51808e05f514e63927f959ae51.tar.gz
emacs-35e1f9d9fcbaab51808e05f514e63927f959ae51.zip
Merge from origin/emacs-24
a5f38fa Fix ChangeLog typo c6400e1 Fix composition of characters from Syriac and Arabis scripts. 7e9dfde python.el: Fix message when sending region. 800260c python.el: Cleanup temp files even with eval errors. ed65b91 Fix for previous commit 2dd5163 python.el: Handle file encoding for shell. 7aa506e Spelling fixes 4cd6d77 * automated/tramp-tests.el (tramp-test17-insert-directory): Do not expect a given order of "." and "..". a41d07b Fix rendering of composed caharacters on the mode line. (Bug#19435) b70977c Small doc markup fixes 73c050c * doc/lispref/modes.texi (Defining Minor Modes, SMIE Lexer): Markup fixes. 1783e6c ChangeLog fix c741b1b TUTORIAL.es: Improve style consistency f89efea TUTORIAL.es: spelling fixes 0d48826 Avoid compiler warning. Conflicts: doc/lispref/ChangeLog doc/lispref/control.texi etc/ChangeLog lisp/ChangeLog src/ChangeLog test/ChangeLog
Diffstat (limited to 'test/automated/python-tests.el')
-rw-r--r--test/automated/python-tests.el271
1 files changed, 271 insertions, 0 deletions
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el
index ab0ab2d54d7..28332ef2ce7 100644
--- a/test/automated/python-tests.el
+++ b/test/automated/python-tests.el
@@ -2446,6 +2446,198 @@ and `python-shell-interpreter-args' in the new shell buffer."
2446 "^\\(o\\.t \\|\\)"))) 2446 "^\\(o\\.t \\|\\)")))
2447 (ignore-errors (delete-file startup-file))))) 2447 (ignore-errors (delete-file startup-file)))))
2448 2448
2449(ert-deftest python-shell-buffer-substring-1 ()
2450 "Selecting a substring of the whole buffer must match its contents."
2451 (python-tests-with-temp-buffer
2452 "
2453class Foo(models.Model):
2454 pass
2455
2456
2457class Bar(models.Model):
2458 pass
2459"
2460 (should (string= (buffer-string)
2461 (python-shell-buffer-substring (point-min) (point-max))))))
2462
2463(ert-deftest python-shell-buffer-substring-2 ()
2464 "Main block should be removed if NOMAIN is non-nil."
2465 (python-tests-with-temp-buffer
2466 "
2467class Foo(models.Model):
2468 pass
2469
2470class Bar(models.Model):
2471 pass
2472
2473if __name__ == \"__main__\":
2474 foo = Foo()
2475 print (foo)
2476"
2477 (should (string= (python-shell-buffer-substring (point-min) (point-max) t)
2478 "
2479class Foo(models.Model):
2480 pass
2481
2482class Bar(models.Model):
2483 pass
2484
2485
2486
2487
2488"))))
2489
2490(ert-deftest python-shell-buffer-substring-3 ()
2491 "Main block should be removed if NOMAIN is non-nil."
2492 (python-tests-with-temp-buffer
2493 "
2494class Foo(models.Model):
2495 pass
2496
2497if __name__ == \"__main__\":
2498 foo = Foo()
2499 print (foo)
2500
2501class Bar(models.Model):
2502 pass
2503"
2504 (should (string= (python-shell-buffer-substring (point-min) (point-max) t)
2505 "
2506class Foo(models.Model):
2507 pass
2508
2509
2510
2511
2512
2513class Bar(models.Model):
2514 pass
2515"))))
2516
2517(ert-deftest python-shell-buffer-substring-4 ()
2518 "Coding cookie should be added for substrings."
2519 (python-tests-with-temp-buffer
2520 "# coding: latin-1
2521
2522class Foo(models.Model):
2523 pass
2524
2525if __name__ == \"__main__\":
2526 foo = Foo()
2527 print (foo)
2528
2529class Bar(models.Model):
2530 pass
2531"
2532 (should (string= (python-shell-buffer-substring
2533 (python-tests-look-at "class Foo(models.Model):")
2534 (progn (python-nav-forward-sexp) (point)))
2535 "# -*- coding: latin-1 -*-
2536
2537class Foo(models.Model):
2538 pass"))))
2539
2540(ert-deftest python-shell-buffer-substring-5 ()
2541 "The proper amount of blank lines is added for a substring."
2542 (python-tests-with-temp-buffer
2543 "# coding: latin-1
2544
2545class Foo(models.Model):
2546 pass
2547
2548if __name__ == \"__main__\":
2549 foo = Foo()
2550 print (foo)
2551
2552class Bar(models.Model):
2553 pass
2554"
2555 (should (string= (python-shell-buffer-substring
2556 (python-tests-look-at "class Bar(models.Model):")
2557 (progn (python-nav-forward-sexp) (point)))
2558 "# -*- coding: latin-1 -*-
2559
2560
2561
2562
2563
2564
2565
2566
2567class Bar(models.Model):
2568 pass"))))
2569
2570(ert-deftest python-shell-buffer-substring-6 ()
2571 "Handle substring with coding cookie in the second line."
2572 (python-tests-with-temp-buffer
2573 "
2574# coding: latin-1
2575
2576class Foo(models.Model):
2577 pass
2578
2579if __name__ == \"__main__\":
2580 foo = Foo()
2581 print (foo)
2582
2583class Bar(models.Model):
2584 pass
2585"
2586 (should (string= (python-shell-buffer-substring
2587 (python-tests-look-at "# coding: latin-1")
2588 (python-tests-look-at "if __name__ == \"__main__\":"))
2589 "# -*- coding: latin-1 -*-
2590
2591
2592class Foo(models.Model):
2593 pass
2594
2595"))))
2596
2597(ert-deftest python-shell-buffer-substring-7 ()
2598 "Ensure first coding cookie gets precedence."
2599 (python-tests-with-temp-buffer
2600 "# coding: utf-8
2601# coding: latin-1
2602
2603class Foo(models.Model):
2604 pass
2605
2606if __name__ == \"__main__\":
2607 foo = Foo()
2608 print (foo)
2609
2610class Bar(models.Model):
2611 pass
2612"
2613 (should (string= (python-shell-buffer-substring
2614 (python-tests-look-at "# coding: latin-1")
2615 (python-tests-look-at "if __name__ == \"__main__\":"))
2616 "# -*- coding: utf-8 -*-
2617
2618
2619class Foo(models.Model):
2620 pass
2621
2622"))))
2623
2624(ert-deftest python-shell-buffer-substring-8 ()
2625 "Ensure first coding cookie gets precedence when sending whole buffer."
2626 (python-tests-with-temp-buffer
2627 "# coding: utf-8
2628# coding: latin-1
2629
2630class Foo(models.Model):
2631 pass
2632"
2633 (should (string= (python-shell-buffer-substring (point-min) (point-max))
2634 "# coding: utf-8
2635
2636
2637class Foo(models.Model):
2638 pass
2639"))))
2640
2449 2641
2450;;; Shell completion 2642;;; Shell completion
2451 2643
@@ -3760,6 +3952,85 @@ foo = True # another comment
3760 (forward-line 1) 3952 (forward-line 1)
3761 (should (python-info-current-line-empty-p)))) 3953 (should (python-info-current-line-empty-p))))
3762 3954
3955(ert-deftest python-info-encoding-from-cookie-1 ()
3956 "Should detect it on first line."
3957 (python-tests-with-temp-buffer
3958 "# coding=latin-1
3959
3960foo = True # another comment
3961"
3962 (should (eq (python-info-encoding-from-cookie) 'latin-1))))
3963
3964(ert-deftest python-info-encoding-from-cookie-2 ()
3965 "Should detect it on second line."
3966 (python-tests-with-temp-buffer
3967 "
3968# coding=latin-1
3969
3970foo = True # another comment
3971"
3972 (should (eq (python-info-encoding-from-cookie) 'latin-1))))
3973
3974(ert-deftest python-info-encoding-from-cookie-3 ()
3975 "Should not be detected on third line (and following ones)."
3976 (python-tests-with-temp-buffer
3977 "
3978
3979# coding=latin-1
3980foo = True # another comment
3981"
3982 (should (not (python-info-encoding-from-cookie)))))
3983
3984(ert-deftest python-info-encoding-from-cookie-4 ()
3985 "Should detect Emacs style."
3986 (python-tests-with-temp-buffer
3987 "# -*- coding: latin-1 -*-
3988
3989foo = True # another comment"
3990 (should (eq (python-info-encoding-from-cookie) 'latin-1))))
3991
3992(ert-deftest python-info-encoding-from-cookie-5 ()
3993 "Should detect Vim style."
3994 (python-tests-with-temp-buffer
3995 "# vim: set fileencoding=latin-1 :
3996
3997foo = True # another comment"
3998 (should (eq (python-info-encoding-from-cookie) 'latin-1))))
3999
4000(ert-deftest python-info-encoding-from-cookie-6 ()
4001 "First cookie wins."
4002 (python-tests-with-temp-buffer
4003 "# -*- coding: iso-8859-1 -*-
4004# vim: set fileencoding=latin-1 :
4005
4006foo = True # another comment"
4007 (should (eq (python-info-encoding-from-cookie) 'iso-8859-1))))
4008
4009(ert-deftest python-info-encoding-from-cookie-7 ()
4010 "First cookie wins."
4011 (python-tests-with-temp-buffer
4012 "# vim: set fileencoding=latin-1 :
4013# -*- coding: iso-8859-1 -*-
4014
4015foo = True # another comment"
4016 (should (eq (python-info-encoding-from-cookie) 'latin-1))))
4017
4018(ert-deftest python-info-encoding-1 ()
4019 "Should return the detected encoding from cookie."
4020 (python-tests-with-temp-buffer
4021 "# vim: set fileencoding=latin-1 :
4022
4023foo = True # another comment"
4024 (should (eq (python-info-encoding) 'latin-1))))
4025
4026(ert-deftest python-info-encoding-2 ()
4027 "Should default to utf-8."
4028 (python-tests-with-temp-buffer
4029 "# No encoding for you
4030
4031foo = True # another comment"
4032 (should (eq (python-info-encoding) 'utf-8))))
4033
3763 4034
3764;;; Utility functions 4035;;; Utility functions
3765 4036