Skip to content

Commit 82a2b96

Browse files
committed
Expand pythonic default directory to the full path.
Process both local and tramp files correctly.
1 parent 62cd002 commit 82a2b96

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

pythonic.el

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@
7272

7373
(defun pythonic-default-directory (&optional from-directory)
7474
"Generate `default-directory' FROM-DIRECTORY."
75-
(concat (pythonic-tramp-connection) (or from-directory "~")))
75+
(let ((default-directory
76+
(concat (pythonic-tramp-connection)
77+
(or from-directory "~"))))
78+
(f-full default-directory)))
7679

7780
(defun pythonic-set-process-environment ()
7881
"Set process environment variables from `python-mode' settings.

test/pythonic-test.el

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
(ert-deftest test-pythonic-default-directory ()
4545
"Run processes in $HOME by default."
46-
(should (s-equals-p "~" (pythonic-default-directory))))
46+
(should (s-equals-p (f-full "~") (pythonic-default-directory))))
4747

4848
(ert-deftest test-pythonic-default-directory-localhost ()
4949
"Pass directory unmodified in clean environment."
@@ -53,13 +53,15 @@
5353
"Default directory must point to the tramp address in the case
5454
remote address was specified in the
5555
`python-shell-interpreter'."
56-
(let ((python-shell-interpreter "/localhost:/path/to/the/python"))
57-
(should (s-equals-p "/localhost:~" (pythonic-default-directory)))))
56+
(let ((python-shell-interpreter "/ssh:test@localhost:/path/to/the/python"))
57+
(should (s-equals-p "/ssh:test@localhost:/home/test/"
58+
(pythonic-default-directory)))))
5859

5960
(ert-deftest test-pythonic-default-directory-virtualenv-remote ()
6061
"Virtual environment `default-directory' on the remote host."
61-
(let ((python-shell-virtualenv-path "/localhost:/vagrant/env"))
62-
(should (s-equals-p "/localhost:~" (pythonic-default-directory)))))
62+
(let ((python-shell-virtualenv-path "/ssh:test@localhost:/vagrant/env"))
63+
(should (s-equals-p "/ssh:test@localhost:/home/test/"
64+
(pythonic-default-directory)))))
6365

6466
;;; Set PYTHONPATH variable.
6567

@@ -194,7 +196,7 @@ remote host."
194196
(call-pythonic :buffer "*out1*"
195197
:cwd "~"
196198
:args '("-c" "from __future__ import print_function; import os; print(os.getcwd())"))
197-
(should (s-equals-p (s-concat (expand-file-name "~") "\n")
199+
(should (s-equals-p (s-concat (f-expand "~") "\n")
198200
(with-current-buffer "*out1*"
199201
(buffer-string)))))
200202

@@ -240,7 +242,7 @@ remote host."
240242
:args '("-c" "from __future__ import print_function; import os; print(os.getcwd())"))))
241243
(while (process-live-p process)
242244
(accept-process-output process))
243-
(should (s-equals-p (s-concat (expand-file-name "~") "\n\nProcess out5 finished\n")
245+
(should (s-equals-p (s-concat (f-expand "~") "\n\nProcess out5 finished\n")
244246
(with-current-buffer "*out5*"
245247
(buffer-string))))))
246248

@@ -312,7 +314,7 @@ remote host."
312314
(ert-deftest test-start-pythonic-default-directory-property ()
313315
"Set `pythonic-default-directory' result as `default-directory' process property."
314316
(let ((default-directorys "~"))
315-
(should (equal "~"
317+
(should (equal (f-full "~")
316318
(process-get
317319
(start-pythonic :process "out" :args '("-V"))
318320
'default-directory)))))

0 commit comments

Comments
 (0)