From 14f6f213ce919c600a6c96ad667cd72e60043e1195d12de550635d65dfd7c75e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Fri, 3 May 2024 22:33:16 +0200 Subject: [PATCH] Sync from SUSE:SLFO:Main python-pytest-virtualenv revision 9bf058bc3faa31da54feffbb79f398c7 --- .gitattributes | 23 ++++++++ _multibuild | 3 + pytest-virtualenv-1.7.0.tar.gz | 3 + python-pytest-virtualenv.changes | 34 ++++++++++++ python-pytest-virtualenv.spec | 95 ++++++++++++++++++++++++++++++++ remove_mock.patch | 29 ++++++++++ remove_virtualenv.patch | 65 ++++++++++++++++++++++ 7 files changed, 252 insertions(+) create mode 100644 .gitattributes create mode 100644 _multibuild create mode 100644 pytest-virtualenv-1.7.0.tar.gz create mode 100644 python-pytest-virtualenv.changes create mode 100644 python-pytest-virtualenv.spec create mode 100644 remove_mock.patch create mode 100644 remove_virtualenv.patch diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/_multibuild b/_multibuild new file mode 100644 index 0000000..fcc7b97 --- /dev/null +++ b/_multibuild @@ -0,0 +1,3 @@ + + test + diff --git a/pytest-virtualenv-1.7.0.tar.gz b/pytest-virtualenv-1.7.0.tar.gz new file mode 100644 index 0000000..d74570b --- /dev/null +++ b/pytest-virtualenv-1.7.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2270ee8822111ec25db48e9d9f2efec32e68483a015b14cd0d92aeccc6ff820f +size 15767 diff --git a/python-pytest-virtualenv.changes b/python-pytest-virtualenv.changes new file mode 100644 index 0000000..0bd3fd3 --- /dev/null +++ b/python-pytest-virtualenv.changes @@ -0,0 +1,34 @@ +------------------------------------------------------------------- +Sat Jun 10 09:44:58 UTC 2023 - ecsos + +- Add %{?sle15_python_module_pythons} + +------------------------------------------------------------------- +Mon Nov 15 07:23:10 UTC 2021 - Steve Kowalik + +- Inject multibuild to break up a build loop. + +------------------------------------------------------------------- +Sun Dec 13 21:55:46 UTC 2020 - Matej Cepl + +- We don't need to break Python 2.7 + +------------------------------------------------------------------- +Fri Dec 11 22:44:02 UTC 2020 - Matej Cepl + +- Add remove_mock.patch to remove dependency on the external mock + package (gh#man-group/pytest-plugins#168). Also add + remove_virtualenv.patch to remove dependency on external + virtualenv package. + +------------------------------------------------------------------- +Mon Jun 3 08:53:22 UTC 2019 - Tomáš Chvátal + +- Update to 1.7.0: + * Support pytest 4 + * Support python 3.7 + +------------------------------------------------------------------- +Wed Feb 13 09:13:26 UTC 2019 - Tomáš Chvátal + +- Initial commit, needed by pytest-runner diff --git a/python-pytest-virtualenv.spec b/python-pytest-virtualenv.spec new file mode 100644 index 0000000..4c7af56 --- /dev/null +++ b/python-pytest-virtualenv.spec @@ -0,0 +1,95 @@ +# +# spec file +# +# Copyright (c) 2021 SUSE LLC +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +%{?!python_module:%define python_module() python-%{**} python3-%{**}} +%global flavor @BUILD_FLAVOR@%{nil} +%if "%{flavor}" == "test" +%define psuffix -test +%bcond_without test +%else +%define psuffix %{nil} +%bcond_with test +%endif +%{?sle15_python_module_pythons} +Name: python-pytest-virtualenv%{psuffix} +Version: 1.7.0 +Release: 0 +Summary: Virtualenv fixture for pytest +License: MIT +URL: https://github.com/manahl/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 +%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} +%endif +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 +Requires: python-pytest-fixture-config +Requires: python-pytest-shutil +Requires: python-setuptools +BuildArch: noarch +%python_subpackages + +%description +Create a Python virtual environment in your test that cleans up on +teardown. The fixture has utility methods to install packages and list +what's installed. + +%prep +%autosetup -p1 -n pytest-virtualenv-%{version} + +%build +%python_build + +%install +%if !%{with test} +%python_install +%python_expand %fdupes %{buildroot}%{$python_sitelib} +%endif + +%check +%if %{with test} +# Requires network access +%pytest -k 'not test_installed_packages' +%endif + +%if !%{with test} +%files %{python_files} +%doc CHANGES.md README.md +%license LICENSE +%{python_sitelib}/* +%endif + +%changelog diff --git a/remove_mock.patch b/remove_mock.patch new file mode 100644 index 0000000..6ec01e9 --- /dev/null +++ b/remove_mock.patch @@ -0,0 +1,29 @@ +--- 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'] diff --git a/remove_virtualenv.patch b/remove_virtualenv.patch new file mode 100644 index 0000000..d4aaa59 --- /dev/null +++ b/remove_virtualenv.patch @@ -0,0 +1,65 @@ +--- + 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 + ++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'] + + CONFIG = FixtureConfig( + virtualenv_executable=os.getenv('VIRTUALENV_FIXTURE_EXECUTABLE', DEFAULT_VIRTUALENV_FIXTURE_EXECUTABLE), +@@ -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)