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.el89
1 files changed, 52 insertions, 37 deletions
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el
index f368f995cae..f84ded8cad2 100644
--- a/test/automated/python-tests.el
+++ b/test/automated/python-tests.el
@@ -1872,6 +1872,23 @@ Using `python-shell-interpreter' and
1872 python-shell-virtualenv-path 1872 python-shell-virtualenv-path
1873 path-separator original-path))))) 1873 path-separator original-path)))))
1874 1874
1875(ert-deftest python-shell-calculate-process-environment-4 ()
1876 "Test `python-shell-unbuffered' modification."
1877 (setenv "PYTHONUNBUFFERED")
1878 (let* ((process-environment
1879 (python-shell-calculate-process-environment)))
1880 ;; Defaults to t
1881 (should python-shell-unbuffered)
1882 (should (string= (getenv "PYTHONUNBUFFERED") "1"))))
1883
1884(ert-deftest python-shell-calculate-process-environment-5 ()
1885 (setenv "PYTHONUNBUFFERED")
1886 "Test `python-shell-unbuffered' modification."
1887 (let* ((python-shell-unbuffered nil)
1888 (process-environment
1889 (python-shell-calculate-process-environment)))
1890 (should (not (getenv "PYTHONUNBUFFERED")))))
1891
1875(ert-deftest python-shell-calculate-exec-path-1 () 1892(ert-deftest python-shell-calculate-exec-path-1 ()
1876 "Test `python-shell-exec-path' modification." 1893 "Test `python-shell-exec-path' modification."
1877 (let* ((original-exec-path exec-path) 1894 (let* ((original-exec-path exec-path)
@@ -1961,8 +1978,9 @@ and `python-shell-interpreter-args' in the new shell buffer."
1961 (should (process-live-p process)) 1978 (should (process-live-p process))
1962 (with-current-buffer shell-buffer 1979 (with-current-buffer shell-buffer
1963 (should (eq major-mode 'inferior-python-mode)) 1980 (should (eq major-mode 'inferior-python-mode))
1964 (should (string= python-shell-interpreter 1981 (should (file-equal-p
1965 (executable-find python-tests-shell-interpreter))) 1982 python-shell-interpreter
1983 (executable-find python-tests-shell-interpreter)))
1966 (should (string= python-shell-interpreter-args "-i")))) 1984 (should (string= python-shell-interpreter-args "-i"))))
1967 (kill-buffer shell-buffer)))) 1985 (kill-buffer shell-buffer))))
1968 1986
@@ -2050,12 +2068,11 @@ and `python-shell-interpreter-args' in the new shell buffer."
2050 (skip-unless (executable-find python-tests-shell-interpreter)) 2068 (skip-unless (executable-find python-tests-shell-interpreter))
2051 (python-tests-with-temp-file 2069 (python-tests-with-temp-file
2052 "" 2070 ""
2053 (let* ((python-shell-interpreter 2071 (let* ((cmd
2054 (executable-find python-tests-shell-interpreter)) 2072 (concat (executable-find python-tests-shell-interpreter) " -i"))
2055 (use-dialog-box) 2073 (use-dialog-box)
2056 (dedicated-process-name (python-shell-get-process-name t)) 2074 (dedicated-process-name (python-shell-get-process-name t))
2057 (dedicated-process 2075 (dedicated-process (python-shell-get-or-create-process cmd t))
2058 (python-shell-get-or-create-process python-shell-interpreter t))
2059 (dedicated-shell-buffer (process-buffer dedicated-process))) 2076 (dedicated-shell-buffer (process-buffer dedicated-process)))
2060 (unwind-protect 2077 (unwind-protect
2061 (progn 2078 (progn
@@ -2073,12 +2090,11 @@ and `python-shell-interpreter-args' in the new shell buffer."
2073 (skip-unless (executable-find python-tests-shell-interpreter)) 2090 (skip-unless (executable-find python-tests-shell-interpreter))
2074 (python-tests-with-temp-file 2091 (python-tests-with-temp-file
2075 "" 2092 ""
2076 (let* ((python-shell-interpreter 2093 (let* ((cmd
2077 (executable-find python-tests-shell-interpreter)) 2094 (concat (executable-find python-tests-shell-interpreter) " -i"))
2078 (use-dialog-box) 2095 (use-dialog-box)
2079 (process-name (python-shell-get-process-name nil)) 2096 (process-name (python-shell-get-process-name nil))
2080 (process 2097 (process (python-shell-get-or-create-process cmd))
2081 (python-shell-get-or-create-process python-shell-interpreter))
2082 (shell-buffer (process-buffer process))) 2098 (shell-buffer (process-buffer process)))
2083 (unwind-protect 2099 (unwind-protect
2084 (progn 2100 (progn
@@ -2088,43 +2104,42 @@ and `python-shell-interpreter-args' in the new shell buffer."
2088 (kill-buffer shell-buffer) 2104 (kill-buffer shell-buffer)
2089 ;; Check there are no processes for current buffer. 2105 ;; Check there are no processes for current buffer.
2090 (should (not (python-shell-get-process)))) 2106 (should (not (python-shell-get-process))))
2091 (ignore-errors (kill-buffer dedicated-shell-buffer)))))) 2107 (ignore-errors (kill-buffer shell-buffer))))))
2092 2108
2093(ert-deftest python-shell-get-or-create-process-3 () 2109(ert-deftest python-shell-get-or-create-process-3 ()
2094 "Check shell dedicated/global process preference." 2110 "Check shell dedicated/global process preference."
2095 (skip-unless (executable-find python-tests-shell-interpreter)) 2111 (skip-unless (executable-find python-tests-shell-interpreter))
2096 (python-tests-with-temp-file 2112 (python-tests-with-temp-file
2097 "" 2113 ""
2098 (let* ((python-shell-interpreter 2114 (let* ((cmd
2099 (executable-find python-tests-shell-interpreter)) 2115 (concat (executable-find python-tests-shell-interpreter) " -i"))
2116 (python-shell-interpreter python-tests-shell-interpreter)
2100 (use-dialog-box) 2117 (use-dialog-box)
2101 (dedicated-process-name (python-shell-get-process-name t)) 2118 (dedicated-process-name (python-shell-get-process-name t))
2102 (global-process) 2119 (global-process)
2103 (dedicated-process)) 2120 (dedicated-process))
2104 (unwind-protect 2121 (progn
2105 (progn 2122 ;; Create global process
2106 ;; Create global process 2123 (run-python cmd nil)
2107 (run-python python-shell-interpreter nil) 2124 (setq global-process (get-buffer-process "*Python*"))
2108 (setq global-process (get-buffer-process "*Python*")) 2125 (should global-process)
2109 (should global-process) 2126 (set-process-query-on-exit-flag global-process nil)
2110 (set-process-query-on-exit-flag global-process nil) 2127 ;; Create dedicated process
2111 ;; Create dedicated process 2128 (run-python cmd t)
2112 (run-python python-shell-interpreter t) 2129 (setq dedicated-process (get-process dedicated-process-name))
2113 (setq dedicated-process (get-process dedicated-process-name)) 2130 (should dedicated-process)
2114 (should dedicated-process) 2131 (set-process-query-on-exit-flag dedicated-process nil)
2115 (set-process-query-on-exit-flag dedicated-process nil) 2132 ;; Prefer dedicated.
2116 ;; Prefer dedicated. 2133 (should (equal (python-shell-get-or-create-process)
2117 (should (equal (python-shell-get-or-create-process) 2134 dedicated-process))
2118 dedicated-process)) 2135 ;; Kill the dedicated so the global takes over.
2119 ;; Kill the dedicated so the global takes over. 2136 (kill-buffer (process-buffer dedicated-process))
2120 (kill-buffer (process-buffer dedicated-process)) 2137 ;; Detect global.
2121 ;; Detect global. 2138 (should (equal (python-shell-get-or-create-process) global-process))
2122 (should (equal (python-shell-get-or-create-process) global-process)) 2139 ;; Kill the global.
2123 ;; Kill the global. 2140 (kill-buffer (process-buffer global-process))
2124 (kill-buffer (process-buffer global-process)) 2141 ;; Check there are no processes for current buffer.
2125 ;; Check there are no processes for current buffer. 2142 (should (not (python-shell-get-process)))))))
2126 (should (not (python-shell-get-process))))
2127 (ignore-errors (kill-buffer dedicated-shell-buffer))))))
2128 2143
2129(ert-deftest python-shell-internal-get-or-create-process-1 () 2144(ert-deftest python-shell-internal-get-or-create-process-1 ()
2130 "Check internal shell process creation fallback." 2145 "Check internal shell process creation fallback."