diff options
Diffstat (limited to 'test/automated/python-tests.el')
| -rw-r--r-- | test/automated/python-tests.el | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index 40505cc7953..fdae235ad38 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | 21 | ||
| 22 | ;;; Code: | 22 | ;;; Code: |
| 23 | 23 | ||
| 24 | (require 'ert) | ||
| 24 | (require 'python) | 25 | (require 'python) |
| 25 | 26 | ||
| 26 | (defmacro python-tests-with-temp-buffer (contents &rest body) | 27 | (defmacro python-tests-with-temp-buffer (contents &rest body) |
| @@ -463,10 +464,10 @@ Class foo(object): | |||
| 463 | " | 464 | " |
| 464 | (python-tests-look-at "3)") | 465 | (python-tests-look-at "3)") |
| 465 | (forward-line 1) | 466 | (forward-line 1) |
| 466 | (= (python-indent-calculate-indentation) 12) | 467 | (should (= (python-indent-calculate-indentation) 8)) |
| 467 | (python-tests-look-at "pass") | 468 | (python-tests-look-at "pass") |
| 468 | (forward-line 1) | 469 | (forward-line 1) |
| 469 | (= (python-indent-calculate-indentation) 8))) | 470 | (should (= (python-indent-calculate-indentation) 8)))) |
| 470 | 471 | ||
| 471 | 472 | ||
| 472 | ;;; Navigation | 473 | ;;; Navigation |
| @@ -1744,6 +1745,53 @@ class Baz(object): | |||
| 1744 | (cons "c (def)" (copy-marker 626))))) | 1745 | (cons "c (def)" (copy-marker 626))))) |
| 1745 | (python-imenu-create-index))))) | 1746 | (python-imenu-create-index))))) |
| 1746 | 1747 | ||
| 1748 | (ert-deftest python-imenu-create-index-2 () | ||
| 1749 | (python-tests-with-temp-buffer | ||
| 1750 | " | ||
| 1751 | class Foo(object): | ||
| 1752 | def foo(self): | ||
| 1753 | def foo1(): | ||
| 1754 | pass | ||
| 1755 | |||
| 1756 | def foobar(self): | ||
| 1757 | pass | ||
| 1758 | " | ||
| 1759 | (goto-char (point-max)) | ||
| 1760 | (should (equal | ||
| 1761 | (list | ||
| 1762 | (list | ||
| 1763 | "Foo (class)" | ||
| 1764 | (cons "*class definition*" (copy-marker 2)) | ||
| 1765 | (list | ||
| 1766 | "foo (def)" | ||
| 1767 | (cons "*function definition*" (copy-marker 21)) | ||
| 1768 | (cons "foo1 (def)" (copy-marker 40))) | ||
| 1769 | (cons "foobar (def)" (copy-marker 78)))) | ||
| 1770 | (python-imenu-create-index))))) | ||
| 1771 | |||
| 1772 | (ert-deftest python-imenu-create-index-3 () | ||
| 1773 | (python-tests-with-temp-buffer | ||
| 1774 | " | ||
| 1775 | class Foo(object): | ||
| 1776 | def foo(self): | ||
| 1777 | def foo1(): | ||
| 1778 | pass | ||
| 1779 | def foo2(): | ||
| 1780 | pass | ||
| 1781 | " | ||
| 1782 | (goto-char (point-max)) | ||
| 1783 | (should (equal | ||
| 1784 | (list | ||
| 1785 | (list | ||
| 1786 | "Foo (class)" | ||
| 1787 | (cons "*class definition*" (copy-marker 2)) | ||
| 1788 | (list | ||
| 1789 | "foo (def)" | ||
| 1790 | (cons "*function definition*" (copy-marker 21)) | ||
| 1791 | (cons "foo1 (def)" (copy-marker 40)) | ||
| 1792 | (cons "foo2 (def)" (copy-marker 77))))) | ||
| 1793 | (python-imenu-create-index))))) | ||
| 1794 | |||
| 1747 | (ert-deftest python-imenu-create-flat-index-1 () | 1795 | (ert-deftest python-imenu-create-flat-index-1 () |
| 1748 | (python-tests-with-temp-buffer | 1796 | (python-tests-with-temp-buffer |
| 1749 | " | 1797 | " |