Closed spookylukey closed 2 years ago
i like this 👍🏼 and wasn't aware of this projectile behaviour.
care to open a pr?
Hey @spookylukey can you give an example on how to make this work with a monorepo structure ?
I've tried using the .dir-locals.el file but no matter what I do, the pytest cwd is always the root of the monorepo.
@dirodriguezm Here are two different layouts I have found work:
Given you have:
And you want the pytest CWD to be 'subdir/':
Add the following .dir-locals.el
as a sibling to .git/
:
((nil .
((projectile-project-compilation-dir . "subdir"))))
Note that you can only have one .dir-locals.el
that takes effect. If you have one in a sub directory, ones in parent directories will be ignored.
Note also that the variable name is projectile-project-compilation-dir
, while projectile-compilation-dir
is a function that uses it.
Don't need .dir-locals.el
at all, instead put a .projectile
inside subdir
If you still can't get it to work, say so, I can give a full example or see if there is something going on with my setup.
Thank you, it worked.
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#L4705It 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.: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
orconftest.py
in different sub-projects, they can be picked up correctly. Running withcwd
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
:This is working for me, I don't know what other complications it might bring.