aboutsummaryrefslogtreecommitdiffstats
path: root/test/automated/python-tests.el
diff options
context:
space:
mode:
Diffstat (limited to 'test/automated/python-tests.el')
-rw-r--r--test/automated/python-tests.el104
1 files changed, 104 insertions, 0 deletions
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el
index 39195fd7086..8c657c38b64 100644
--- a/test/automated/python-tests.el
+++ b/test/automated/python-tests.el
@@ -725,6 +725,110 @@ def b()
725 (python-tests-self-insert ":") 725 (python-tests-self-insert ":")
726 (should (= (current-indentation) 0)))) 726 (should (= (current-indentation) 0))))
727 727
728(ert-deftest python-indent-region-1 ()
729 "Test indentation case from Bug#18843."
730 (let ((contents "
731def foo ():
732 try:
733 pass
734 except:
735 pass
736"))
737 (python-tests-with-temp-buffer
738 contents
739 (python-indent-region (point-min) (point-max))
740 (should (string= (buffer-substring-no-properties (point-min) (point-max))
741 contents)))))
742
743(ert-deftest python-indent-region-2 ()
744 "Test region indentation on comments."
745 (let ((contents "
746def f():
747 if True:
748 pass
749
750# This is
751# some multiline
752# comment
753"))
754 (python-tests-with-temp-buffer
755 contents
756 (python-indent-region (point-min) (point-max))
757 (should (string= (buffer-substring-no-properties (point-min) (point-max))
758 contents)))))
759
760(ert-deftest python-indent-region-3 ()
761 "Test region indentation on comments."
762 (let ((contents "
763def f():
764 if True:
765 pass
766# This is
767# some multiline
768# comment
769")
770 (expected "
771def f():
772 if True:
773 pass
774 # This is
775 # some multiline
776 # comment
777"))
778 (python-tests-with-temp-buffer
779 contents
780 (python-indent-region (point-min) (point-max))
781 (should (string= (buffer-substring-no-properties (point-min) (point-max))
782 expected)))))
783
784(ert-deftest python-indent-region-4 ()
785 "Test region indentation block starts, dedenders and enders."
786 (let ((contents "
787def f():
788 if True:
789a = 5
790 else:
791 a = 10
792 return a
793")
794 (expected "
795def f():
796 if True:
797 a = 5
798 else:
799 a = 10
800 return a
801"))
802 (python-tests-with-temp-buffer
803 contents
804 (python-indent-region (point-min) (point-max))
805 (should (string= (buffer-substring-no-properties (point-min) (point-max))
806 expected)))))
807
808(ert-deftest python-indent-region-5 ()
809 "Test region indentation leaves strings untouched (start delimiter)."
810 (let ((contents "
811def f():
812'''
813this is
814a multiline
815string
816'''
817")
818 (expected "
819def f():
820 '''
821this is
822a multiline
823string
824'''
825"))
826 (python-tests-with-temp-buffer
827 contents
828 (python-indent-region (point-min) (point-max))
829 (should (string= (buffer-substring-no-properties (point-min) (point-max))
830 expected)))))
831
728 832
729;;; Navigation 833;;; Navigation
730 834