Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
galaunay committed Oct 17, 2019
1 parent da84a5d commit 8569df1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Cask
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
(package "elpy" "1.31.0" "Emacs Python Development Environment")

(depends-on "company" "0.9.10")
(depends-on "find-file-in-project" "5.7.4")
(depends-on "find-file-in-project" "5.7.7")
(depends-on "highlight-indentation" "0.7.0")
(depends-on "pyvenv" "1.2")
(depends-on "pyvenv" "1.20")
(depends-on "yasnippet" "0.13.0")
(depends-on "s" "1.12.0")

Expand Down
6 changes: 4 additions & 2 deletions elpy-rpc.el
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,10 @@ During the execution of BODY the following variables are available:
(file-name-directory
current-environment-binaries)))))
;; No need to change of venv if they are the same
(same-venv (file-equal-p current-environment
(elpy-rpc-get-or-create-virtualenv)))
(same-venv (or (string= current-environment
(elpy-rpc-get-virtualenv-path))
(file-equal-p current-environment
(elpy-rpc-get-virtualenv-path))))
current-environment-is-deactivated)
(unless same-venv
(pyvenv-activate (elpy-rpc-get-or-create-virtualenv))
Expand Down
4 changes: 1 addition & 3 deletions test/elpy-rpc-get-virtualenv-path-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@
(elpy-testcase ()
(let ((elpy-rpc-virtualenv-path 'system)
(old-venv pyvenv-virtual-env))
(should-not (string-match "\\(travis/virtualenv\\|.virtualenvs\\)"
(elpy-rpc-get-virtualenv-path)))
(pyvenv-workon "elpy-test-venv")
(should-not (string-match "\\(travis/virtualenv\\|.virtualenvs\\)"
(should-not (string-match "elpy-test-venv"
(elpy-rpc-get-virtualenv-path)))
(if old-venv
(pyvenv-activate old-venv)
Expand Down
2 changes: 1 addition & 1 deletion test/elpy-rpc-reinstall-venv-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
(should-not (file-exists-p (concat
(file-name-as-directory rpc-venv-path)
"additional-file")))
(should (string= messages "Are you sure you want to reinstall the virtualenv in '/home/glaunay/.virtualenvs/elpy-test-venv' (every manual modifications will be lost) ? `elpy-rpc-virtualenv-path' was set to '/home/glaunay/.virtualenvs/elpy-test-venv', but this virtualenv does not exist, create it ? Automatically install the RPC dependencies from PyPI (needed for completion, autoformatting and documentation) ? ")))))))
(should (= 0 (string-match "Are you sure you want to reinstall the virtualenv in '[^']*' (every manual modifications will be lost) \\? `elpy-rpc-virtualenv-path' was set to '[^']*', but this virtualenv does not exist, create it \\? Automatically install the RPC dependencies from PyPI (needed for completion, autoformatting and documentation) \\? " messages))))))))
16 changes: 15 additions & 1 deletion test/test-helper.el
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@
elpy-dir
(getenv "PYTHONPATH")))
(add-to-list 'process-environment "ELPY_TEST=1"))
;; Travis is using virtualenvs to test specific version of python
;; we need to use it as the system environment
(advice-add 'elpy-rpc-get-virtualenv-path
:around (lambda (fun &rest args)
(if (and (getenv "TRAVIS")
(or (eq elpy-rpc-virtualenv-path 'global)
(eq elpy-rpc-virtualenv-path 'system)))
(expand-file-name
(concat
"~/virtualenv/"
"python"
(getenv "TRAVIS_PYTHON_VERSION")))
(apply fun args))))

(require 'elpy)
;; Travis regularly has some lag for some reason.
(setq elpy-rpc-timeout 10)
Expand Down Expand Up @@ -40,7 +54,7 @@
(mletf* ((y-or-n-p (&rest rest) t))
(elpy-config)
(with-current-buffer "*Elpy Config*"
(print (buffer-string))))
(message (buffer-substring-no-properties (point-min) (point-max)))))

(defmacro with-temp-dir (name &rest body)
"Create a temporary directory and bind the symbol NAME to the path.
Expand Down

0 comments on commit 8569df1

Please sign in to comment.