man-group / man-group/pytest-plugins

[Windows] Basic run operation uses wrong environment

Open
#166 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug windows
Dominant language
Python
Stars
597
Forks
89
PR merge metrics
No merged PRs in 30d

Description

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 =

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 ==============================
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the test_run reproduction in virtualenv-run.py and run it on Windows to confirm the failure. Trace the Windows path used by virtualenv.run and verify the command executes in the created virtual environment, then confirm the test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
operating-systems, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.