Skip to content

Commit 91fdc5d

Browse files
committed
Respect tramp connection in the proper environment check.
Save pythonic-tramp-connection within :connection process property rather default-directory. This will not require to pass from-directory argument into pythonic-proper-environment-p predicate.
1 parent ffb3bc2 commit 91fdc5d

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

pythonic.el

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,17 @@ process flag."
209209
(process-put process
210210
'pythonic
211211
(list
212-
:default-directory default-directory
213-
:environment python-shell-process-environment
212+
:connection (pythonic-tramp-connection)
213+
:pythonpath (pythonic-get-pythonpath)
214214
:path (pythonic-get-path)
215-
:pythonpath (pythonic-get-pythonpath)))
215+
:environment python-shell-process-environment))
216216
process)))
217217

218218
(defun pythonic-proper-environment-p (process)
219219
"Determine if python environment has been changed since PROCESS was started."
220220
(--if-let (process-get process 'pythonic)
221221
(and
222+
(equal (plist-get it :connection) (pythonic-tramp-connection))
222223
(equal (plist-get it :pythonpath) (pythonic-get-pythonpath))
223224
(equal (plist-get it :path) (pythonic-get-path))
224225
(equal (plist-get it :environment) python-shell-process-environment))

test/pythonic-test.el

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,19 @@ Respect remote PYTHONPATH value."
365365
(setq tramp-current-connection)
366366
(sleep-for 0.5)))
367367

368-
(ert-deftest test-start-pythonic-default-directory-property ()
369-
"Set `pythonic-default-directory' result as `default-directory' process property."
370-
(let ((default-directorys "~"))
371-
(should (equal (f-full "~")
372-
(plist-get
373-
(process-get
374-
(start-pythonic :process "out" :args '("-V"))
375-
'pythonic)
376-
:default-directory)))))
368+
(ert-deftest test-start-pythonic-connection-property ()
369+
"Set `pythonic-tramp-connection' result as `connection' process property."
370+
(unwind-protect
371+
(let ((python-shell-interpreter "/ssh:test@localhost:/path/to/the/python"))
372+
(should (equal "/ssh:test@localhost:"
373+
(plist-get
374+
(process-get
375+
(start-pythonic :process "out" :args '("-V"))
376+
'pythonic)
377+
:connection))))
378+
(kill-buffer "*tramp/ssh test@localhost*")
379+
(setq tramp-current-connection)
380+
(sleep-for 0.5)))
377381

378382
(ert-deftest test-start-pythonic-environment-property ()
379383
"Set `python-shell-process-environment' as `environment' process property."
@@ -416,6 +420,16 @@ change since process was start."
416420
(python-shell-process-environment '("TEST=t")))
417421
(should-not (pythonic-proper-environment-p process))))
418422

423+
(ert-deftest test-pythonic-proper-environment-p-change-host ()
424+
"`pythonic-proper-environment-p' is null if tramp host was changed."
425+
;; `unwind-protect' block is unnecessary here because non of tramp
426+
;; connection will be opened below. First process starts locally,
427+
;; proper environment check will stop at connection strings
428+
;; comparison, non of remote PATH or PYTHONPATH checks will be made.
429+
(let* ((process (start-pythonic :process "out" :args '("-V")))
430+
(python-shell-interpreter "/ssh:test@localhost:/path/to/the/python"))
431+
(should-not (pythonic-proper-environment-p process))))
432+
419433
;;; Activate/deactivate environment.
420434

421435
(ert-deftest test-pythonic-activate ()

0 commit comments

Comments
 (0)