[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 287bce9: python.el: Fix local/remote shell environm
From: |
Fabián Ezequiel Gallina |
Subject: |
[Emacs-diffs] master 287bce9: python.el: Fix local/remote shell environment setup |
Date: |
Mon, 06 Jul 2015 23:08:43 +0000 |
branch: master
commit 287bce988895b104c33d53faacfffd91d8d8e0f1
Author: Fabián Ezequiel Gallina <address@hidden>
Commit: Fabián Ezequiel Gallina <address@hidden>
python.el: Fix local/remote shell environment setup
* lisp/progmodes/python.el (python-shell-with-environment): Fix
remote/local environment setup.
* test/automated/python-tests.el (python-shell-with-environment-1)
(python-shell-with-environment-2): New tests.
---
lisp/progmodes/python.el | 35 ++++++++++++++++---------------
test/automated/python-tests.el | 44 ++++++++++++++++++++++++++++++++-------
2 files changed, 54 insertions(+), 25 deletions(-)
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 1c0f105..95814fa 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2060,23 +2060,24 @@ execution of body. If `default-directory' points to a
remote
machine then modifies `tramp-remote-process-environment' and
`tramp-remote-path' instead."
(declare (indent 0) (debug (body)))
- (let ((remote-p (file-remote-p default-directory)))
- `(let ((process-environment
- (if ,remote-p
- process-environment
- (python-shell-calculate-process-environment)))
- (tramp-remote-process-environment
- (if ,remote-p
- (python-shell-calculate-process-environment)
- tramp-remote-process-environment))
- (exec-path
- (if ,remote-p
- (python-shell-calculate-exec-path)
- exec-path))
- (tramp-remote-path
- (if ,remote-p
- (python-shell-calculate-exec-path)
- tramp-remote-path)))
+ (let ((remote-p (make-symbol "remote-p")))
+ `(let* ((,remote-p (file-remote-p default-directory))
+ (process-environment
+ (if ,remote-p
+ process-environment
+ (python-shell-calculate-process-environment)))
+ (tramp-remote-process-environment
+ (if ,remote-p
+ (python-shell-calculate-process-environment)
+ tramp-remote-process-environment))
+ (exec-path
+ (if ,remote-p
+ exec-path
+ (python-shell-calculate-exec-path)))
+ (tramp-remote-path
+ (if ,remote-p
+ (python-shell-calculate-exec-path)
+ tramp-remote-path)))
,(macroexp-progn body))))
(defvar python-shell--prompt-calculated-input-regexp nil
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el
index 2ed0746..d490f7f 100644
--- a/test/automated/python-tests.el
+++ b/test/automated/python-tests.el
@@ -27,6 +27,7 @@
;; Dependencies for testing:
(require 'electric)
(require 'hideshow)
+(require 'tramp-sh)
(defmacro python-tests-with-temp-buffer (contents &rest body)
@@ -2463,17 +2464,12 @@ Using `python-shell-interpreter' and
(ert-deftest python-shell-calculate-process-environment-3 ()
"Test `python-shell-virtualenv-root' modification."
- (let* ((original-path (or (getenv "PATH") ""))
- (python-shell-virtualenv-root
+ (let* ((python-shell-virtualenv-root
(directory-file-name user-emacs-directory))
(process-environment
(python-shell-calculate-process-environment)))
(should (not (getenv "PYTHONHOME")))
- (should (string= (getenv "VIRTUAL_ENV") python-shell-virtualenv-root))
- (should (equal (getenv "PATH")
- (format "%s/bin%s%s"
- python-shell-virtualenv-root
- path-separator original-path)))))
+ (should (string= (getenv "VIRTUAL_ENV") python-shell-virtualenv-root))))
(ert-deftest python-shell-calculate-process-environment-4 ()
"Test `python-shell-unbuffered' modification."
@@ -2503,7 +2499,7 @@ Using `python-shell-interpreter' and
original-exec-path)))))
(ert-deftest python-shell-calculate-exec-path-2 ()
- "Test `python-shell-exec-path' modification."
+ "Test `python-shell-virtualenv-root' modification."
(let* ((original-exec-path exec-path)
(python-shell-virtualenv-root
(directory-file-name (expand-file-name user-emacs-directory)))
@@ -2514,6 +2510,38 @@ Using `python-shell-interpreter' and
(format "%s/bin" python-shell-virtualenv-root)
original-exec-path))))))
+(ert-deftest python-shell-with-environment-1 ()
+ "Test with local `default-directory'."
+ (let* ((original-exec-path exec-path)
+ (python-shell-virtualenv-root
+ (directory-file-name (expand-file-name user-emacs-directory))))
+ (python-shell-with-environment
+ (should (equal
+ exec-path
+ (append (cons
+ (format "%s/bin" python-shell-virtualenv-root)
+ original-exec-path))))
+ (should (not (getenv "PYTHONHOME")))
+ (should (string= (getenv "VIRTUAL_ENV") python-shell-virtualenv-root)))))
+
+(ert-deftest python-shell-with-environment-2 ()
+ "Test with remote `default-directory'."
+ (let* ((default-directory "/ssh::/example/dir/")
+ (original-exec-path tramp-remote-path)
+ (original-process-environment tramp-remote-process-environment)
+ (python-shell-virtualenv-root
+ (directory-file-name (expand-file-name user-emacs-directory))))
+ (python-shell-with-environment
+ (should (equal
+ tramp-remote-path
+ (append (cons
+ (format "%s/bin" python-shell-virtualenv-root)
+ original-exec-path))))
+ (let ((process-environment tramp-remote-process-environment))
+ (should (not (getenv "PYTHONHOME")))
+ (should (string= (getenv "VIRTUAL_ENV")
+ python-shell-virtualenv-root))))))
+
(ert-deftest python-shell-make-comint-1 ()
"Check comint creation for global shell buffer."
(skip-unless (executable-find python-tests-shell-interpreter))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 287bce9: python.el: Fix local/remote shell environment setup,
Fabián Ezequiel Gallina <=