Skip to content

Commit

Permalink
Fix library root discovery when in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
galaunay committed Nov 20, 2019
1 parent f3461ee commit 333924b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions elpy.el
Original file line number Diff line number Diff line change
Expand Up @@ -1349,11 +1349,17 @@ This is marked with 'setup.py', 'setup.cfg' or 'pyproject.toml'."
That is, if you have /foo/package/module.py, it will return /foo,
so that import package.module will pick up module.py."
(locate-dominating-file default-directory
(lambda (dir)
(not (file-exists-p
(format "%s/__init__.py"
dir))))))
(let ((directory default-directory)
(root
(locate-dominating-file default-directory
(lambda (dir)
(not (file-exists-p
(concat
(file-name-as-directory dir)
"__init__.py")))))))
(when (string-match "\\<tests$" (directory-file-name root))
(setq root (car (split-string root "tests"))))
root))

(defun elpy-project--read-project-variable (prompt)
"Prompt the user for a variable name to set project-wide using PROMPT."
Expand Down

0 comments on commit 333924b

Please sign in to comment.