Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add {envsitedir} substitution. #72

Closed
pytoxbot opened this issue Sep 17, 2016 · 10 comments
Closed

Add {envsitedir} substitution. #72

pytoxbot opened this issue Sep 17, 2016 · 10 comments

Comments

@pytoxbot
Copy link

It seems tricky to figure out the site-packages dir from outside the virtualenv (distutils.sysconfig is inadequate if the interpreter version changes), but it would make certain hacks to get file-based test runners to cooperate with 2to3 much easier.

@pytoxbot
Copy link
Author

Original comment by @g2p

@takafumi It can be useful for import-based discovery, but many tools work more reliably or only with a full path. Some tests also try to access resources from the current directory.

@pytoxbot
Copy link
Author

Original comment by @tkf

How about changedir = {envtmpdir}? I usually do this when I use 2to3.

@pytoxbot
Copy link
Author

Original comment by @hpk42

I think we deifnitely need recommendations how to deal with 2to3. Not sure i get to it in the next weeks. Using "envsitepackagesdir" is kind of a hack, it should be possible to have things working more easily. Haven't thought in depth about it yet, though.

@pytoxbot
Copy link
Author

Original comment by @g2p

Ah, and without 2to3, this snippet also prevents py.test reporting an import file mismatch between the build/ directory (which pytest tried to collect) and the vcs version (which ends up imported).

@pytoxbot
Copy link
Author

Original comment by @g2p

auto2to3 -m pytest is another option outside tox, but inside tox it would need some extra flags to only cover vcs files, so it's not very interesting.

@pytoxbot
Copy link
Author

Original comment by @g2p

py.test finds the non-2to3 source from the vcs checkout in both cases.
I think it's due to the implicit '' at the start of sys.path.
The other workaround I know, besides this one (haven't tried it as my tests aren't in a separate package), is to change directories (that works well).

@pytoxbot
Copy link
Author

Original comment by @hpk42

in which case does the normal "--cov=mypkg" not work? And what happens, if you do do "py.test --cov=mypkg --pyargs mypkg" btw?

@pytoxbot
Copy link
Author

Original comment by @g2p

I have this snippet that works reliably in the presence of 2to3 (edit: the multiprocessing thing was a red herring), should I mention it in one of the examples?

command={envbindir}/py.test --cov={envsitepackagesdir}/mypkg {envsitepackagesdir}/mypkg

@pytoxbot
Copy link
Author

Original comment by @hpk42

Add {envsitepackagesdir} substitution. Closes #72.

→ <>

@pytoxbot
Copy link
Author

Original comment by @g2p

https://bitbucket.org/hpk42/tox/pull-request/30/

@tox-dev tox-dev locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant