Skip to content

Commit 70bbce9

Browse files
committed
Avoid random file-error in tests.
Sleep for half second to give ssh session finally close.
1 parent 82a2b96 commit 70bbce9

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

test/pythonic-test.el

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
(ert-deftest test-pythonic-executable-interpreter-remote ()
2222
"Python executable on the remote host."
23-
(let ((python-shell-interpreter "/localhost:/path/to/the/python"))
23+
(let ((python-shell-interpreter "/ssh:test@localhost:/path/to/the/python"))
2424
(should (s-equals-p "/path/to/the/python" (pythonic-executable)))))
2525

2626
(ert-deftest test-pythonic-executable-virtualenv ()
@@ -30,7 +30,7 @@
3030

3131
(ert-deftest test-pythonic-executable-virtualenv-remote ()
3232
"Virtual environment python executable on the remote host."
33-
(let ((python-shell-virtualenv-path "/localhost:/vagrant/env"))
33+
(let ((python-shell-virtualenv-path "/ssh:test@localhost:/vagrant/env"))
3434
(should (s-equals-p "/vagrant/env/bin/python" (pythonic-executable)))))
3535

3636
(ert-deftest test-pythonic-executable-virtualenv-windows ()
@@ -53,15 +53,23 @@
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 "/ssh:test@localhost:/path/to/the/python"))
57-
(should (s-equals-p "/ssh:test@localhost:/home/test/"
58-
(pythonic-default-directory)))))
56+
(unwind-protect
57+
(let ((python-shell-interpreter "/ssh:test@localhost:/path/to/the/python"))
58+
(should (s-equals-p "/ssh:test@localhost:/home/test/"
59+
(pythonic-default-directory))))
60+
(kill-buffer "*tramp/ssh test@localhost*")
61+
(setq tramp-current-connection)
62+
(sleep-for 0.5)))
5963

6064
(ert-deftest test-pythonic-default-directory-virtualenv-remote ()
6165
"Virtual environment `default-directory' on the remote host."
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)))))
66+
(unwind-protect
67+
(let ((python-shell-virtualenv-path "/ssh:test@localhost:/vagrant/env"))
68+
(should (s-equals-p "/ssh:test@localhost:/home/test/"
69+
(pythonic-default-directory))))
70+
(kill-buffer "*tramp/ssh test@localhost*")
71+
(setq tramp-current-connection)
72+
(sleep-for 0.5)))
6573

6674
;;; Set PYTHONPATH variable.
6775

@@ -104,7 +112,8 @@ successively calls."
104112
(with-current-buffer "*tramp/ssh test@localhost*"
105113
(buffer-string)))))
106114
(kill-buffer "*tramp/ssh test@localhost*")
107-
(setq tramp-current-connection)))
115+
(setq tramp-current-connection)
116+
(sleep-for 0.5)))
108117

109118
(ert-deftest test-pythonic-set-pythonpath-variable-tramp-exists ()
110119
"Set PYTHONPATH according to the
@@ -121,7 +130,8 @@ Respect existing PYTHONPATH on the remote host."
121130
(with-current-buffer "*tramp/ssh test@localhost*"
122131
(buffer-string)))))
123132
(kill-buffer "*tramp/ssh test@localhost*")
124-
(setq tramp-current-connection)))
133+
(setq tramp-current-connection)
134+
(sleep-for 0.5)))
125135

126136
(ert-deftest test-pythonic-set-pythonpath-variable-tramp-few-calls ()
127137
"Set PYTHONPATH doesn't double entries in the variable on
@@ -136,7 +146,8 @@ successively calls on the remote host."
136146
(with-current-buffer "*tramp/ssh test@localhost*"
137147
(buffer-string)))))
138148
(kill-buffer "*tramp/ssh test@localhost*")
139-
(setq tramp-current-connection)))
149+
(setq tramp-current-connection)
150+
(sleep-for 0.5)))
140151

141152
;;; PATH variable.
142153

@@ -159,7 +170,8 @@ successively calls on the remote host."
159170
(with-current-buffer "*tramp/ssh test@localhost*"
160171
(buffer-string)))))
161172
(kill-buffer "*tramp/ssh test@localhost*")
162-
(setq tramp-current-connection)))
173+
(setq tramp-current-connection)
174+
(sleep-for 0.5)))
163175

164176
;;; Extra variables.
165177

@@ -182,7 +194,8 @@ remote host."
182194
(with-current-buffer "*tramp/ssh test@localhost*"
183195
(buffer-string)))))
184196
(kill-buffer "*tramp/ssh test@localhost*")
185-
(setq tramp-current-connection)))
197+
(setq tramp-current-connection)
198+
(sleep-for 0.5)))
186199

187200
;;; Call process.
188201

0 commit comments

Comments
 (0)