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

[Windows] Basic run operation uses wrong environment #166

Open
jaraco opened this issue Aug 8, 2020 · 0 comments
Open

[Windows] Basic run operation uses wrong environment #166

jaraco opened this issue Aug 8, 2020 · 0 comments

Comments

@jaraco
Copy link
Contributor

jaraco commented Aug 8, 2020

Given this simple test:

def test_run(virtualenv):
    import sys
    cmd = ['python', '-c', 'import sys; print(sys.prefix)']
    res = virtualenv.run(cmd, capture=True, text=True).strip()
    assert sys.prefix not in res

This test runs a command in the virtualenv emitting the sys.prefix and expects it not to be the sys.prefix of the test runner.

It passes on Unix-like OSs, but fails on Windows with this trace:

PS C:\Users\jaraco\draft> env/Scripts/pytest '\\vmware-host\shared folders\home\draft\virtualenv-run.py'
============================= test session starts =============================
platform win32 -- Python 3.8.3, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
rootdir: \\vmware-host\shared folders\home\draft
plugins: shutil-1.7.0, virtualenv-1.7.0, xonsh-0.9.18
collected 1 item

\\vmware-host\shared folders\home\draft\virtualenv-run.py F              [100%]

================================== FAILURES ===================================
__________________________________ test_run ___________________________________

virtualenv = <pytest_virtualenv.VirtualEnv object at 0x00000222DB0C6E50>

    def test_run(virtualenv):
        import sys
        cmd = ['python', '-c', 'import sys; print(sys.prefix)']
        res = virtualenv.run(cmd, capture=True, text=True).strip()
>       assert sys.prefix not in res
E       AssertionError: assert 'c:\\users\\...\\draft\\env' not in 'c:\\users\\...\\draft\\env'
E         'c:\\users\\jaraco\\draft\\env' is contained here:
E           c:\users\jaraco\draft\env

\\vmware-host\shared folders\home\draft\virtualenv-run.py:5: AssertionError
---------------------------- Captured stdout setup ----------------------------
created virtual environment CPython3.8.3.final.0-64 in 703ms

  creator CPython3Windows(dest=C:\Users\jaraco\AppData\Local\Temp\tmppmdecetw\.env, clear=False, global=False)

  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\jaraco\AppData\Local\pypa\virtualenv)

    added seed packages: pip==20.2.1, setuptools==49.2.1, wheel==0.34.2

  activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

=========================== short test summary info ===========================
FAILED \\vmware-host\shared folders\home\draft\virtualenv-run.py::test_run - ...
============================== 1 failed in 1.23s ==============================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants