-
Notifications
You must be signed in to change notification settings - Fork 233
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
Running with pytest-xdist changes sys.path #376
Comments
Also, xdist is setting PYTHONPATH to the launch directory and empty string. This was what really hurt my tests. |
Does anyone know why |
Thanks @alexmazurik, but that's only when using Lines 257 to 260 in f283ddd
This was added by d81ffaa, which states:
Not sure what was the problem at the time, but perhaps this can be removed then? |
I applied this patch as a quick test: diff --git a/xdist/remote.py b/xdist/remote.py
index b0092e0..a845d2b 100644
--- a/xdist/remote.py
+++ b/xdist/remote.py
@@ -253,11 +253,11 @@ def remote_initconfig(option_dict, args):
if __name__ == "__channelexec__":
channel = channel # noqa
workerinput, args, option_dict = channel.receive()
- importpath = os.getcwd()
- sys.path.insert(0, importpath) # XXX only for remote situations
- os.environ["PYTHONPATH"] = (
- importpath + os.pathsep + os.environ.get("PYTHONPATH", "")
- )
+ #importpath = os.getcwd()
+ #sys.path.insert(0, importpath) # XXX only for remote situations
+ #os.environ["PYTHONPATH"] = (
+ # importpath + os.pathsep + os.environ.get("PYTHONPATH", "")
+ #)
os.environ["PYTEST_XDIST_WORKER"] = workerinput["workerid"]
os.environ["PYTEST_XDIST_WORKER_COUNT"] = str(workerinput["workercount"])
# os.environ['PYTHONPATH'] = importpath and all of xdist's tests still pass. |
I very vaugely recall this was used to ensure correctness in multi interpreter usage id like to do some archeology before dropping it |
Oh that makes sense. I think today such multi interpreter usages are rare, given that we now have tox. But it is definitely interesting to know what you can dig. 😁 |
Released in |
FTR I've found out that this is still happening: pypa/setuptools#2459 (comment). |
…ke the repair at the session level and only when xdist is present.
…on 52.0.0 Jason R. Coombs (17): Remove support for easy_install-based downloads for fetch_build_eggs (setup_requires). Add changelog. Rely on pytest-enabler to enable pytest-xdist when present and enabled. Avoid indirection in src_dir Rely on rootdir to determine the source. Avoids coupling with position in the test suite. Extract workaround for pytest-dev/pytest-xdist#376 as a fixture. Invoke the repair at the session level and only when xdist is present. Simplify get_build_backend to simply allow override of cwd. Restore test_build_sdist_relative_path_import to its former simple implementation. Simplify and enhance tests in test_build_meta. Ref #2459. Add changelog. Prefer 'rootdir' for resolving the project root. Remove eggsecutable Update changelog. Remove easy_install script and module. Remove 'main' function from 'easy_install'. Update changelog Bump version: 51.3.3 → 52.0.0 Sviatoslav Sydorenko (8): Parallelize the test runs via pytest-xdist Sanitize CWD out of sys.path in xdist mode Clarify `test_build_sdist_relative_path_import` Make `get_build_backend` cwd path customizable Replace `tmpdir_cwd` fixture with `tmp_path` Make `test_pip_upgrade_from_source` xdist-friendly Isolate src for `test_distutils_adoption` Use tmp src copy in `test_clean_env_install`
A simple test to show sys.path (and then fail, to always see the output):
The second entry in sys.path is different: without xdist, it's the bin directory of the virtualenv. With xdist, it's an empty string (current directory).
xdist shouldn't change this, it means my tests behave differently under the two scenarios.
The text was updated successfully, but these errors were encountered: