Sync from SUSE:SLFO:Main python-pytest-virtualenv revision 69c2ed0d916547d81c64c4a46a36dfcb

This commit is contained in:
Adrian Schröter 2024-12-13 12:13:49 +01:00
parent 14f6f213ce
commit 917afa7a52
6 changed files with 64 additions and 102 deletions

BIN
pytest-virtualenv-1.7.0.tar.gz (Stored with Git LFS)

Binary file not shown.

BIN
pytest-virtualenv-1.8.0.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,3 +1,25 @@
-------------------------------------------------------------------
Mon Nov 4 11:47:43 UTC 2024 - Daniel Garcia <daniel.garcia@suse.com>
- Remove not needed python-setuptools-git
-------------------------------------------------------------------
Tue Oct 22 06:08:51 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>
- Update to 1.8.0:
* Drop support for Python 2 and <3.6, removing compatibility code.
* Use stdlib unittest.mock instead of mock package.
* Removed usage of path.py and path in favour of pathlib.
* Modernised package.
* Added delete_workspace parameter to VirtualEnv.
* Removed extras_require.
- Switch to pyproject macros.
- No more greedy globs in %files.
- Removed patches, included upstream:
* remove_mock.patch
- Refreshed remove_virtualenv.patch
- Do not test with Python 3.12 and above due to an upstream bug.
-------------------------------------------------------------------
Sat Jun 10 09:44:58 UTC 2023 - ecsos <ecsos@opensuse.org>

View File

@ -1,7 +1,7 @@
#
# spec file
# spec file for package python-pytest-virtualenv
#
# Copyright (c) 2021 SUSE LLC
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -16,9 +16,11 @@
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "test"
# https://github.com/man-group/pytest-plugins/issues/220
%define skip_python312 1
%define skip_python313 1
%define psuffix -test
%bcond_without test
%else
@ -27,38 +29,26 @@
%endif
%{?sle15_python_module_pythons}
Name: python-pytest-virtualenv%{psuffix}
Version: 1.7.0
Version: 1.8.0
Release: 0
Summary: Virtualenv fixture for pytest
License: MIT
URL: https://github.com/manahl/pytest-plugins
URL: https://github.com/man-group/pytest-plugins
Source: https://files.pythonhosted.org/packages/source/p/pytest-virtualenv/pytest-virtualenv-%{version}.tar.gz
# PATCH-FIX-UPSTREAM remove_mock.patch gh#man-group/pytest-plugins#168 mcepl@suse.com
# remove dependency on the external module mock
Patch0: remove_mock.patch
# PATCH-FIX-UPSTREAM remove_mock.patch gh#man-group/pytest-plugins#168 mcepl@suse.com
# and while at it, we can remove dependency on the external module
# virtualenv as well
Patch1: remove_virtualenv.patch
# PATCH-FIX-OPENSUSE remove dependency on the external module virtualenv
Patch0: remove_virtualenv.patch
%if %{with test}
BuildRequires: %{python_module path.py}
BuildRequires: %{python_module pytest-fixture-config}
BuildRequires: %{python_module pytest-shutil}
BuildRequires: %{python_module pytest-virtualenv}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module pytest-virtualenv = %{version}}
%endif
BuildRequires: %{python_module setuptools-git}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
%if 0%{?suse_version} <= 1500
BuildRequires: %{python_module mock}
BuildRequires: %{python_module virtualenv}
%endif
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-path.py
Requires: python-importlib-metadata
Requires: python-pytest
Requires: python-pytest-fixture-config
Requires: python-pytest-shutil
Requires: python-setuptools
BuildArch: noarch
%python_subpackages
@ -71,25 +61,27 @@ what's installed.
%autosetup -p1 -n pytest-virtualenv-%{version}
%build
%python_build
%pyproject_wheel
%install
%if !%{with test}
%python_install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%endif
%check
%if %{with test}
# Requires network access
%pytest -k 'not test_installed_packages'
%pytest -k 'not (test_installed_packages or test_install_)'
%endif
%if !%{with test}
%files %{python_files}
%doc CHANGES.md README.md
%license LICENSE
%{python_sitelib}/*
%{python_sitelib}/pytest_virtualenv.py
%pycache_only %{python_sitelib}/__pycache__/pytest_virtualenv*.pyc
%{python_sitelib}/pytest_virtualenv-%{version}.dist-info
%endif
%changelog

View File

@ -1,29 +0,0 @@
--- a/tests/unit/test_venv.py
+++ b/tests/unit/test_venv.py
@@ -1,4 +1,7 @@
-import mock
+try:
+ from unittest.mock import patch
+except ImportError:
+ from mock import patch
import pytest_virtualenv as venv
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'):
- with mock.patch.object(venv.Workspace, 'run') as run:
+ with patch.object(venv.Workspace, 'run') as run:
venv.VirtualEnv()
call = run.mock_calls[0]
assert 'PYTHONPATH' not in call[2]['env']
@@ -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'):
- with mock.patch.object(venv.Workspace, 'run') as run:
+ with patch.object(venv.Workspace, 'run') as run:
venv.VirtualEnv()
call = run.mock_calls[0]
assert 'PYTHONPATH' not in call[2]['env']

View File

@ -1,31 +1,17 @@
---
pytest_virtualenv.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/pytest_virtualenv.py
+++ b/pytest_virtualenv.py
@@ -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
Index: pytest-virtualenv-1.8.0/pytest_virtualenv.py
===================================================================
--- pytest-virtualenv-1.8.0.orig/pytest_virtualenv.py
+++ pytest-virtualenv-1.8.0/pytest_virtualenv.py
@@ -25,7 +25,7 @@ class FixtureConfig(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']
+if PY2:
+ DEFAULT_VIRTUALENV_FIXTURE_EXECUTABLE = [sys.executable, '-m', 'virtualenv']
+else:
+ DEFAULT_VIRTUALENV_FIXTURE_EXECUTABLE = [sys.executable, '-m', 'venv']
+DEFAULT_VIRTUALENV_FIXTURE_EXECUTABLE = [sys.executable, '-m', 'venv']
CONFIG = FixtureConfig(
virtualenv_executable=os.getenv('VIRTUALENV_FIXTURE_EXECUTABLE', DEFAULT_VIRTUALENV_FIXTURE_EXECUTABLE),
@@ -78,7 +84,7 @@ class PackageEntry(object):
@@ -82,7 +82,7 @@ class PackageEntry(object):
def match(self, package_type):
if package_type is self.ANY:
@ -34,32 +20,23 @@
elif package_type is self.REL:
if self.isrel:
return True
@@ -137,7 +143,8 @@ class VirtualEnv(Workspace):
@@ -146,7 +146,6 @@ 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
Index: pytest-virtualenv-1.8.0/setup.py
===================================================================
--- pytest-virtualenv-1.8.0.orig/setup.py
+++ pytest-virtualenv-1.8.0/setup.py
@@ -21,7 +21,6 @@ classifiers = [
install_requires = ['pytest-fixture-config',
'pytest-shutil',
'pytest',
- 'virtualenv',
'importlib-metadata',
]
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)