forked from pool/python-pytest-virtualenv
Accepting request 855629 from home:mcepl:branches:devel:tools:scm
- We don't need to break Python 2.7 OBS-URL: https://build.opensuse.org/request/show/855629 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-virtualenv?expand=0&rev=8
This commit is contained in:
parent
1b1a2d9997
commit
359af771ed
@ -1,3 +1,8 @@
|
||||
-------------------------------------------------------------------
|
||||
Sun Dec 13 21:55:46 UTC 2020 - Matej Cepl <mcepl@suse.com>
|
||||
|
||||
- We don't need to break Python 2.7
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Dec 11 22:44:02 UTC 2020 - Matej Cepl <mcepl@suse.com>
|
||||
|
||||
|
@ -38,6 +38,10 @@ BuildRequires: %{python_module pytest-shutil}
|
||||
BuildRequires: %{python_module pytest}
|
||||
BuildRequires: %{python_module setuptools-git}
|
||||
BuildRequires: %{python_module setuptools}
|
||||
%if 0%{?suse_version} <= 1500
|
||||
BuildRequires: %{python_module mock}
|
||||
BuildRequires: %{python_module virtualenv}
|
||||
%endif
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: python-rpm-macros
|
||||
Requires: python-path.py
|
||||
@ -63,7 +67,8 @@ what's installed.
|
||||
%python_expand %fdupes %{buildroot}%{$python_sitelib}
|
||||
|
||||
%check
|
||||
%pytest
|
||||
# Requires network access
|
||||
%pytest -k 'not test_installed_packages'
|
||||
|
||||
%files %{python_files}
|
||||
%doc CHANGES.md README.md
|
||||
|
@ -1,12 +1,15 @@
|
||||
--- a/tests/unit/test_venv.py
|
||||
+++ b/tests/unit/test_venv.py
|
||||
@@ -1,4 +1,4 @@
|
||||
@@ -1,4 +1,7 @@
|
||||
-import mock
|
||||
+from unittest.mock import patch
|
||||
+try:
|
||||
+ from unittest.mock import patch
|
||||
+except ImportError:
|
||||
+ from mock import patch
|
||||
|
||||
import pytest_virtualenv as venv
|
||||
from pytest_shutil import env
|
||||
@@ -6,7 +6,7 @@ from pytest_shutil import env
|
||||
@@ -6,7 +9,7 @@ from pytest_shutil import env
|
||||
|
||||
def test_PYTHONPATH_not_present_in_testing_env_if_set():
|
||||
with env.set_env('PYTHONPATH', 'fred'):
|
||||
@ -15,7 +18,7 @@
|
||||
venv.VirtualEnv()
|
||||
call = run.mock_calls[0]
|
||||
assert 'PYTHONPATH' not in call[2]['env']
|
||||
@@ -18,7 +18,7 @@ def test_PYTHONPATH_not_present_in_testi
|
||||
@@ -18,7 +21,7 @@ def test_PYTHONPATH_not_present_in_testi
|
||||
|
||||
def test_PYTHONPATH_not_present_in_testing_env_if_unset():
|
||||
with env.no_env('PYTHONPATH'):
|
||||
|
@ -4,20 +4,62 @@
|
||||
|
||||
--- a/pytest_virtualenv.py
|
||||
+++ b/pytest_virtualenv.py
|
||||
@@ -21,7 +21,7 @@ class FixtureConfig(Config):
|
||||
@@ -15,13 +15,19 @@ from pytest_shutil.workspace import Work
|
||||
from pytest_shutil import run, cmdline
|
||||
from pytest_fixture_config import Config, yield_requires_config
|
||||
|
||||
+PY2 = sys.version_info[0] == 2
|
||||
+
|
||||
|
||||
class FixtureConfig(Config):
|
||||
__slots__ = ('virtualenv_executable')
|
||||
|
||||
+
|
||||
# Default values for system resource locations - patch this to change defaults
|
||||
# Can be a string or list of them
|
||||
-DEFAULT_VIRTUALENV_FIXTURE_EXECUTABLE = [sys.executable, '-m', 'virtualenv']
|
||||
+DEFAULT_VIRTUALENV_FIXTURE_EXECUTABLE = [sys.executable, '-m', 'venv']
|
||||
+if PY2:
|
||||
+ DEFAULT_VIRTUALENV_FIXTURE_EXECUTABLE = [sys.executable, '-m', 'virtualenv']
|
||||
+else:
|
||||
+ DEFAULT_VIRTUALENV_FIXTURE_EXECUTABLE = [sys.executable, '-m', 'venv']
|
||||
|
||||
CONFIG = FixtureConfig(
|
||||
virtualenv_executable=os.getenv('VIRTUALENV_FIXTURE_EXECUTABLE', DEFAULT_VIRTUALENV_FIXTURE_EXECUTABLE),
|
||||
@@ -137,7 +137,6 @@ class VirtualEnv(Workspace):
|
||||
@@ -78,7 +84,7 @@ class PackageEntry(object):
|
||||
|
||||
def match(self, package_type):
|
||||
if package_type is self.ANY:
|
||||
- return True
|
||||
+ return True
|
||||
elif package_type is self.REL:
|
||||
if self.isrel:
|
||||
return True
|
||||
@@ -137,7 +143,8 @@ class VirtualEnv(Workspace):
|
||||
cmd = [self.virtualenv_cmd]
|
||||
else:
|
||||
cmd = list(self.virtualenv_cmd)
|
||||
- cmd.extend(['-p', python or cmdline.get_real_python_executable()])
|
||||
+ if PY2:
|
||||
+ cmd.extend(['-p', python or cmdline.get_real_python_executable()])
|
||||
cmd.extend(self.args)
|
||||
cmd.append(str(self.virtualenv))
|
||||
self.run(cmd)
|
||||
--- a/tests/integration/test_tmpvirtualenv.py
|
||||
+++ b/tests/integration/test_tmpvirtualenv.py
|
||||
@@ -5,6 +5,8 @@ import textwrap
|
||||
|
||||
import pytest_virtualenv as venv
|
||||
|
||||
+PY2 = sys.version_info[0] == 2
|
||||
+
|
||||
|
||||
def check_member(name, ips):
|
||||
return name in ips
|
||||
@@ -15,4 +17,5 @@ def test_installed_packages():
|
||||
ips = v.installed_packages()
|
||||
assert len(ips) > 0
|
||||
check_member('pip', ips)
|
||||
- check_member('virtualenv', ips)
|
||||
\ No newline at end of file
|
||||
+ if PY2:
|
||||
+ check_member('virtualenv', ips)
|
||||
|
Loading…
x
Reference in New Issue
Block a user