Skip to content

Commit 19c18c8

Browse files
authored
Merge pull request #91 from hroncok/i79
Instead of using the virtualenv command, use -m virtualenv
2 parents 27646c7 + 6bfb0f1 commit 19c18c8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pytest-virtualenv/pytest_virtualenv.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ class FixtureConfig(Config):
2020
__slots__ = ('virtualenv_executable')
2121

2222
# Default values for system resource locations - patch this to change defaults
23-
DEFAULT_VIRTUALENV_FIXTURE_EXECUTABLE = (cmdline.which('virtualenv') + ['virtualenv'])[0]
23+
# Can be a string or list of them
24+
DEFAULT_VIRTUALENV_FIXTURE_EXECUTABLE = [sys.executable, '-m', 'virtualenv']
2425

2526
CONFIG = FixtureConfig(
2627
virtualenv_executable=os.getenv('VIRTUALENV_FIXTURE_EXECUTABLE', DEFAULT_VIRTUALENV_FIXTURE_EXECUTABLE),
@@ -132,9 +133,11 @@ def __init__(self, env=None, workspace=None, name='.env', python=None, args=None
132133
del(self.env['PYTHONPATH'])
133134

134135
self.virtualenv_cmd = CONFIG.virtualenv_executable
135-
cmd = [self.virtualenv_cmd,
136-
'-p', python or cmdline.get_real_python_executable()
137-
]
136+
if isinstance(self.virtualenv_cmd, str):
137+
cmd = [self.virtualenv_cmd]
138+
else:
139+
cmd = list(self.virtualenv_cmd)
140+
cmd.extend(['-p', python or cmdline.get_real_python_executable()])
138141
cmd.extend(self.args)
139142
cmd.append(str(self.virtualenv))
140143
self.run(cmd)

0 commit comments

Comments
 (0)