-
-
Notifications
You must be signed in to change notification settings - Fork 522
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
chdir away from tox.ini directory during test #54
Comments
Original comment by @brechtm In general, it's a good idea to place your packages in an Read these for why you should use an |
Original comment by @brechtm As I understand it, Python always first searches the working directory when importing a package or module. The working directory (where tox.ini lives) is typically a repository checkout. Often the package source code is stored in a directory that matches the package name. In that case, this directory will shadow the installed package, and tox is in fact not testing the installed package. This is a critical problem for packages that modify (2to3) source files on installation. Wouldn't it be best that the working directory is always a temporary, empty directory to make sure there's nothing strange going on? |
Original comment by @hpk42 right, the idea of "testlocations" would be to do copying of them to some environment directory in order to perform 2to3 or other transforms. In general, i'd like tox to learn to generate setup.py/setup.cfg for a project (so everything could be based on tox.ini using PEP426 compliant metadata). If that happens we could think about also generating test packages and installing them, based on the same metadata. |
Original comment by @jenisys The "test" directory (not: "tests") contains an empty "init.py" file. A feature like "testlocations = ..." would be good idea. Testing is the primary use case. |
Original comment by @hpk42 @Jenisis does you "tests" directory contain an init.py by chance? This would lead pytest to insert the parent dir of "tests" and if you packages lives at the same level this can lead to importing the non-installed package. Clearly, this is too unpredictable. I think tox should grow an "testlocations = ..." or similar option which allow to specify where the test directoryies/file live (with glob patterns etc.). If that option is specified, they would be copied to the environment and there could be an optional "2to3" step before running tests there. |
Original comment by @jenisys I just ran into the same issue. The project is using nose as test runner. Therefore, I cannot switch. As an experiment I replaced One changedir command can be applied by using the
The default value for |
Original comment by @RonnyPfannschmidt also there are various setups of pytest tests that will actually use the installed version even from the same cwd |
Original comment by @dholth Oh, there is an option 'changedir' |
tox seems to run code with the directory containing tox.ini in the PYTHONPATH, loading code from the checkout instead of the installed sdist inside the virtualenv. Instead, tox should chdir to catch 'forgot to include something in sdist' errors.
The text was updated successfully, but these errors were encountered: