ionrock / pytest-el

Run py.test on testing functions, classes, modules and entire suites in Emacs.
55 stars 26 forks source link

No such directory found via CDPATH environment variable #22

Closed sivakov512 closed 7 years ago

sivakov512 commented 7 years ago

My pytest.ini is located in the src directory of the project's root. I have this setting in .dir-locals.el: (setq pytest-project-root-test (lambda (dirname) (equal dirname "src")))

When I run pytest-all, pytest-module or any other I get "No such directory found via CDPATH environment variable".

What am I doing wrong? :)

ionrock commented 7 years ago

@cryptomaniac512 Take a closer look at the dir locals docs as I don't think you can execute arbitrary lisp that way. Usually you define the mode when you want the variables included.

Here is an example where something dynamic is performed.

((python-mode . ((eval . (setq exec-path (append exec-path `(,"~/bin")))))))

I've copy pasta'd that from another example, so please read the docs to get a better idea of how to use it. Usually it is just setting static values.

sivakov512 commented 7 years ago

I show only part of the configuration, somehow related to the problem :)

sivakov512 commented 7 years ago

Here is complete code of my .dir-locals.el

((nil . ((eval . (progn
                   (add-to-list 'exec-path (concat (locate-dominating-file default-directory dir-locals-file) "src/frontend/node_modules/.bin/"))
                   (venv-workon "py3_backoffice")
                   (setq python-shell-interpreter "python"
                     python-shell-interpreter-args (concat "-i " (expand-file-name (locate-dominating-file default-directory dir-locals-file)) "src/manage.py shell --plain"))
                   (setq pytest-project-root-test (lambda (dirname) (equal dirname "src")))
                   (setq js-indent-level 2))))))
sivakov512 commented 7 years ago

If I remove (setq pytest-project-root-test (lambda (dirname) (equal dirname "src"))) then pytest starts, but not in needed directory. How can I set correctly directory for running test? This is src directory inside project root.

sivakov512 commented 7 years ago

Solved with (add-to-list 'pytest-project-root-files "pytest.ini")