Skip to content

Respect projectile-compilation-dir for working directory. #57

@spookylukey

Description

@spookylukey

The projectile-test-project command and other commands set default-directory to (projectile-compilation-dir) - see https://github.com/bbatsov/projectile/blob/2c948f3a8ed378ae5fd800d2c66aece06ba058b8/projectile.el#L4705

It would be helpful if emacs-python-pytest did the same. It means that you can customize the cwd for a test run using your .dir-locals.el file e.g.:

 (python-mode .
              ((projectile-project-compilation-dir . "my_sub_project_dir")))

This seems like a much nicer workaround for the case of monorepos than the one mentioned in the readme. For example, this method means that if we have multiple different pytest.ini or conftest.py in different sub-projects, they can be picked up correctly. Running with cwd as the root directory is not going to work for many monorepo setups.

Implementation seems to be as simple as changing the definition of python-pytest---project-root:

(defun python-pytest--project-root ()
  "Find the project root directory."
  (let ((projectile-require-project-root nil))
    (projectile-compilation-dir)))

This is working for me, I don't know what other complications it might bring.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions