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.el99
1 files changed, 44 insertions, 55 deletions
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el
index de20a80ea52..fd427941bf1 100644
--- a/test/automated/python-tests.el
+++ b/test/automated/python-tests.el
@@ -1775,52 +1775,41 @@ def f():
1775(defvar python-tests-shell-interpreter "python") 1775(defvar python-tests-shell-interpreter "python")
1776 1776
1777(ert-deftest python-shell-get-process-name-1 () 1777(ert-deftest python-shell-get-process-name-1 ()
1778 "Check process name calculation on different scenarios." 1778 "Check process name calculation sans `buffer-file-name'."
1779 (python-tests-with-temp-buffer 1779 (python-tests-with-temp-buffer
1780 "" 1780 ""
1781 (should (string= (python-shell-get-process-name nil) 1781 (should (string= (python-shell-get-process-name nil)
1782 python-shell-buffer-name)) 1782 python-shell-buffer-name))
1783 ;; When the `current-buffer' doesn't have `buffer-file-name', even 1783 (should (string= (python-shell-get-process-name t)
1784 ;; if dedicated flag is non-nil should not include its name. 1784 (format "%s[%s]" python-shell-buffer-name (buffer-name))))))
1785 (should (string= (python-shell-get-process-name t) 1785
1786 python-shell-buffer-name))) 1786(ert-deftest python-shell-get-process-name-2 ()
1787 "Check process name calculation with `buffer-file-name'."
1787 (python-tests-with-temp-file 1788 (python-tests-with-temp-file
1788 "" 1789 ""
1789 ;; `buffer-file-name' is non-nil but the dedicated flag is nil and 1790 ;; `buffer-file-name' is non-nil but the dedicated flag is nil and
1790 ;; should be respected. 1791 ;; should be respected.
1791 (should (string= (python-shell-get-process-name nil) 1792 (should (string= (python-shell-get-process-name nil)
1792 python-shell-buffer-name)) 1793 python-shell-buffer-name))
1793 (should (string= 1794 (should (string=
1794 (python-shell-get-process-name t) 1795 (python-shell-get-process-name t)
1795 (format "%s[%s]" python-shell-buffer-name buffer-file-name))))) 1796 (format "%s[%s]" python-shell-buffer-name (buffer-name))))))
1796 1797
1797(ert-deftest python-shell-internal-get-process-name-1 () 1798(ert-deftest python-shell-internal-get-process-name-1 ()
1798 "Check the internal process name is config-unique." 1799 "Check the internal process name is buffer-unique sans `buffer-file-name'."
1799 (let* ((python-shell-interpreter python-tests-shell-interpreter) 1800 (python-tests-with-temp-buffer
1800 (python-shell-interpreter-args "") 1801 ""
1801 (python-shell-prompt-regexp ">>> ") 1802 (should (string= (python-shell-internal-get-process-name)
1802 (python-shell-prompt-block-regexp "[.][.][.] ") 1803 (format "%s[%s]" python-shell-internal-buffer-name (buffer-name))))))
1803 (python-shell-setup-codes "") 1804
1804 (python-shell-process-environment "") 1805(ert-deftest python-shell-internal-get-process-name-2 ()
1805 (python-shell-extra-pythonpaths "") 1806 "Check the internal process name is buffer-unique with `buffer-file-name'."
1806 (python-shell-exec-path "") 1807 (python-tests-with-temp-file
1807 (python-shell-virtualenv-path "") 1808 ""
1808 (expected (python-tests-with-temp-buffer 1809 (should (string= (python-shell-internal-get-process-name)
1809 "" (python-shell-internal-get-process-name)))) 1810 (format "%s[%s]" python-shell-internal-buffer-name (buffer-name))))))
1810 ;; Same configurations should match. 1811
1811 (should 1812(ert-deftest python-shell-calculate-command-1 ()
1812 (string= expected
1813 (python-tests-with-temp-buffer
1814 "" (python-shell-internal-get-process-name))))
1815 (let ((python-shell-interpreter-args "-B"))
1816 ;; A minimal change should generate different names.
1817 (should
1818 (not (string=
1819 expected
1820 (python-tests-with-temp-buffer
1821 "" (python-shell-internal-get-process-name))))))))
1822
1823(ert-deftest python-shell-parse-command-1 ()
1824 "Check the command to execute is calculated correctly. 1813 "Check the command to execute is calculated correctly.
1825Using `python-shell-interpreter' and 1814Using `python-shell-interpreter' and
1826`python-shell-interpreter-args'." 1815`python-shell-interpreter-args'."
@@ -1832,7 +1821,7 @@ Using `python-shell-interpreter' and
1832 (format "%s %s" 1821 (format "%s %s"
1833 python-shell-interpreter 1822 python-shell-interpreter
1834 python-shell-interpreter-args) 1823 python-shell-interpreter-args)
1835 (python-shell-parse-command))))) 1824 (python-shell-calculate-command)))))
1836 1825
1837(ert-deftest python-shell-calculate-process-environment-1 () 1826(ert-deftest python-shell-calculate-process-environment-1 ()
1838 "Test `python-shell-process-environment' modification." 1827 "Test `python-shell-process-environment' modification."
@@ -1857,17 +1846,17 @@ Using `python-shell-interpreter' and
1857 path-separator original-pythonpath))))) 1846 path-separator original-pythonpath)))))
1858 1847
1859(ert-deftest python-shell-calculate-process-environment-3 () 1848(ert-deftest python-shell-calculate-process-environment-3 ()
1860 "Test `python-shell-virtualenv-path' modification." 1849 "Test `python-shell-virtualenv-root' modification."
1861 (let* ((original-path (or (getenv "PATH") "")) 1850 (let* ((original-path (or (getenv "PATH") ""))
1862 (python-shell-virtualenv-path 1851 (python-shell-virtualenv-root
1863 (directory-file-name user-emacs-directory)) 1852 (directory-file-name user-emacs-directory))
1864 (process-environment 1853 (process-environment
1865 (python-shell-calculate-process-environment))) 1854 (python-shell-calculate-process-environment)))
1866 (should (not (getenv "PYTHONHOME"))) 1855 (should (not (getenv "PYTHONHOME")))
1867 (should (string= (getenv "VIRTUAL_ENV") python-shell-virtualenv-path)) 1856 (should (string= (getenv "VIRTUAL_ENV") python-shell-virtualenv-root))
1868 (should (equal (getenv "PATH") 1857 (should (equal (getenv "PATH")
1869 (format "%s/bin%s%s" 1858 (format "%s/bin%s%s"
1870 python-shell-virtualenv-path 1859 python-shell-virtualenv-root
1871 path-separator original-path))))) 1860 path-separator original-path)))))
1872 1861
1873(ert-deftest python-shell-calculate-process-environment-4 () 1862(ert-deftest python-shell-calculate-process-environment-4 ()
@@ -1900,13 +1889,13 @@ Using `python-shell-interpreter' and
1900(ert-deftest python-shell-calculate-exec-path-2 () 1889(ert-deftest python-shell-calculate-exec-path-2 ()
1901 "Test `python-shell-exec-path' modification." 1890 "Test `python-shell-exec-path' modification."
1902 (let* ((original-exec-path exec-path) 1891 (let* ((original-exec-path exec-path)
1903 (python-shell-virtualenv-path 1892 (python-shell-virtualenv-root
1904 (directory-file-name (expand-file-name user-emacs-directory))) 1893 (directory-file-name (expand-file-name user-emacs-directory)))
1905 (exec-path (python-shell-calculate-exec-path))) 1894 (exec-path (python-shell-calculate-exec-path)))
1906 (should (equal 1895 (should (equal
1907 exec-path 1896 exec-path
1908 (append (cons 1897 (append (cons
1909 (format "%s/bin" python-shell-virtualenv-path) 1898 (format "%s/bin" python-shell-virtualenv-root)
1910 original-exec-path)))))) 1899 original-exec-path))))))
1911 1900
1912(ert-deftest python-shell-make-comint-1 () 1901(ert-deftest python-shell-make-comint-1 ()
@@ -1922,7 +1911,7 @@ Using `python-shell-interpreter' and
1922 (shell-buffer 1911 (shell-buffer
1923 (python-tests-with-temp-buffer 1912 (python-tests-with-temp-buffer
1924 "" (python-shell-make-comint 1913 "" (python-shell-make-comint
1925 (python-shell-parse-command) proc-name))) 1914 (python-shell-calculate-command) proc-name)))
1926 (process (get-buffer-process shell-buffer))) 1915 (process (get-buffer-process shell-buffer)))
1927 (unwind-protect 1916 (unwind-protect
1928 (progn 1917 (progn
@@ -1943,7 +1932,7 @@ Using `python-shell-interpreter' and
1943 (shell-buffer 1932 (shell-buffer
1944 (python-tests-with-temp-buffer 1933 (python-tests-with-temp-buffer
1945 "" (python-shell-make-comint 1934 "" (python-shell-make-comint
1946 (python-shell-parse-command) proc-name nil t))) 1935 (python-shell-calculate-command) proc-name nil t)))
1947 (process (get-buffer-process shell-buffer))) 1936 (process (get-buffer-process shell-buffer)))
1948 (unwind-protect 1937 (unwind-protect
1949 (progn 1938 (progn
@@ -2010,7 +1999,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
2010 (setenv "PYTHONSTARTUP" startup-file) 1999 (setenv "PYTHONSTARTUP" startup-file)
2011 (python-tests-with-temp-buffer 2000 (python-tests-with-temp-buffer
2012 "" (python-shell-make-comint 2001 "" (python-shell-make-comint
2013 (python-shell-parse-command) proc-name nil)))) 2002 (python-shell-calculate-command) proc-name nil))))
2014 (process (get-buffer-process shell-buffer))) 2003 (process (get-buffer-process shell-buffer)))
2015 (unwind-protect 2004 (unwind-protect
2016 (progn 2005 (progn
@@ -2040,10 +2029,10 @@ and `python-shell-interpreter-args' in the new shell buffer."
2040 (dedicated-proc-name (python-shell-get-process-name t)) 2029 (dedicated-proc-name (python-shell-get-process-name t))
2041 (global-shell-buffer 2030 (global-shell-buffer
2042 (python-shell-make-comint 2031 (python-shell-make-comint
2043 (python-shell-parse-command) global-proc-name)) 2032 (python-shell-calculate-command) global-proc-name))
2044 (dedicated-shell-buffer 2033 (dedicated-shell-buffer
2045 (python-shell-make-comint 2034 (python-shell-make-comint
2046 (python-shell-parse-command) dedicated-proc-name)) 2035 (python-shell-calculate-command) dedicated-proc-name))
2047 (global-process (get-buffer-process global-shell-buffer)) 2036 (global-process (get-buffer-process global-shell-buffer))
2048 (dedicated-process (get-buffer-process dedicated-shell-buffer))) 2037 (dedicated-process (get-buffer-process dedicated-shell-buffer)))
2049 (unwind-protect 2038 (unwind-protect
@@ -3767,7 +3756,7 @@ def foo(a, b, c):
3767 . "from IPython.core.completerlib import module_completion") 3756 . "from IPython.core.completerlib import module_completion")
3768 (python-shell-completion-string-code 3757 (python-shell-completion-string-code
3769 . "';'.join(get_ipython().Completer.all_completions('''%s'''))\n") 3758 . "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
3770 (python-shell-virtualenv-path 3759 (python-shell-virtualenv-root
3771 . "/home/user/.virtualenvs/project")))) 3760 . "/home/user/.virtualenvs/project"))))
3772 (with-current-buffer buffer 3761 (with-current-buffer buffer
3773 (kill-all-local-variables) 3762 (kill-all-local-variables)