diff --git a/minimal-dependencies.patch b/minimal-dependencies.patch new file mode 100644 index 0000000..5888fdb --- /dev/null +++ b/minimal-dependencies.patch @@ -0,0 +1,121 @@ +From bbe277f55cd69de23cdd32d277cc30e837ef70b3 Mon Sep 17 00:00:00 2001 +From: Michael Howitz +Date: Thu, 30 Jan 2025 09:14:32 +0100 +Subject: [PATCH] Add tests for minimal dependencies. + +Add `copy` extra to include the `zope.copy` dependency. + +Fixes #5. +--- + .meta.toml | 16 +++++++++++++++- + CHANGES.rst | 3 +++ + setup.py | 17 ++++++++++++++--- + src/zope/location/testing.py | 10 ++++++++++ + src/zope/location/tests/test_configure.py | 12 +++++++++++- + src/zope/location/tests/test_pickling.py | 3 +++ + tox.ini | 10 ++++++++++ + 7 files changed, 66 insertions(+), 5 deletions(-) + create mode 100644 src/zope/location/testing.py + +diff --git a/setup.py b/setup.py +index c12779a..f5b72bd 100644 +--- a/setup.py ++++ b/setup.py +@@ -37,8 +37,11 @@ def read(*rnames): + 'zope.component >= 4.0.1', + ] + +-TESTS_REQUIRE = ZCML_REQUIRES + COMPONENT_REQUIRES + [ ++COPY_REQUIRES = [ + 'zope.copy >= 4.0', ++] ++ ++TESTS_REQUIRE = [ + 'zope.testrunner', + ] + +@@ -57,7 +60,7 @@ def read(*rnames): + + '\n\n' + + read('CHANGES.rst') + ), +- license='ZPL 2.1', ++ license='ZPL-2.1', + keywords=('zope location structural'), + classifiers=[ + 'Development Status :: 5 - Production/Stable', +@@ -93,7 +96,15 @@ def read(*rnames): + extras_require={ + 'zcml': ZCML_REQUIRES, + 'component': COMPONENT_REQUIRES, +- 'test': TESTS_REQUIRE, ++ 'copy': COPY_REQUIRES, ++ 'test-minimal': TESTS_REQUIRE, ++ 'test-component': TESTS_REQUIRE + COMPONENT_REQUIRES + ZCML_REQUIRES, ++ 'test': ( ++ TESTS_REQUIRE ++ + ZCML_REQUIRES ++ + COMPONENT_REQUIRES ++ + COPY_REQUIRES ++ ), + 'docs': DOCS_REQUIRE, + }, + include_package_data=True, +diff --git a/src/zope/location/testing.py b/src/zope/location/testing.py +new file mode 100644 +index 0000000..bf28b3f +--- /dev/null ++++ b/src/zope/location/testing.py +@@ -0,0 +1,10 @@ ++import importlib ++import unittest ++ ++ ++def skipUnlessImportable(module: str): ++ try: ++ importlib.import_module(module) ++ except ModuleNotFoundError: # pragma: no cover ++ return unittest.skip(f"{module!r} not importable") ++ return lambda func: func +diff --git a/src/zope/location/tests/test_configure.py b/src/zope/location/tests/test_configure.py +index 332faa5..5f1bf4f 100644 +--- a/src/zope/location/tests/test_configure.py ++++ b/src/zope/location/tests/test_configure.py +@@ -15,12 +15,22 @@ + """ + import unittest + ++from zope.location.testing import skipUnlessImportable + ++ ++@skipUnlessImportable('zope.component') + class Test_ZCML_loads(unittest.TestCase): + + def test_it(self): + import zope.component # no registrations made if not present +- ADAPTERS_REGISTERED = 4 ++ ++ try: ++ import zope.copy ++ ADAPTERS_REGISTERED = 4 ++ except ModuleNotFoundError: # pragma: no cover ++ ADAPTERS_REGISTERED = 3 ++ else: ++ del zope.copy + from zope.configuration.xmlconfig import XMLConfig + from zope.configuration.xmlconfig import _clearContext + from zope.configuration.xmlconfig import _getContext +diff --git a/src/zope/location/tests/test_pickling.py b/src/zope/location/tests/test_pickling.py +index ddcc274..4c19709 100644 +--- a/src/zope/location/tests/test_pickling.py ++++ b/src/zope/location/tests/test_pickling.py +@@ -13,7 +13,10 @@ + ############################################################################## + import unittest + ++from zope.location.testing import skipUnlessImportable + ++ ++@skipUnlessImportable('zope.copy') + class LocationCopyHookTests(unittest.TestCase): + + def _getTargetClass(self): diff --git a/python-zope.location.changes b/python-zope.location.changes index 4181266..0769411 100644 --- a/python-zope.location.changes +++ b/python-zope.location.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Thu Jan 30 12:35:12 UTC 2025 - Markéta Machová + +- Add minimal-dependencies.patch fixing the issue with test. + ------------------------------------------------------------------- Fri Jan 3 10:47:30 UTC 2025 - Markéta Machová diff --git a/python-zope.location.spec b/python-zope.location.spec index 6a3fda1..739cf0d 100644 --- a/python-zope.location.spec +++ b/python-zope.location.spec @@ -34,6 +34,8 @@ License: ZPL-2.1 Group: Development/Languages/Python URL: https://www.python.org/pypi/zope.location Source: https://files.pythonhosted.org/packages/source/z/zope.location/zope.location-%{version}.tar.gz +# PATCH-FIX-UPSTREAM https://github.com/zopefoundation/zope.location/pull/14 Add tests for minimal dependencies. +Patch: minimal-dependencies.patch BuildRequires: %{python_module pip} BuildRequires: %{python_module wheel} BuildRequires: %{python_module zope.schema >= 4.2.2} @@ -56,7 +58,7 @@ BuildRequires: %{python_module zope.testrunner} In Zope3, location are special objects that has a structural location. %prep -%setup -q -n zope.location-%{version} +%autosetup -p1 -n zope.location-%{version} rm -rf src/zope.location.egg-info %build @@ -70,8 +72,6 @@ rm -rf src/zope.location.egg-info %if %{with test} %check -# https://github.com/zopefoundation/zope.location/issues/12 -rm src/zope/location/tests/test_configure.py %python_expand PYTHONPATH=src %{_bindir}/zope-testrunner-%{$python_bin_suffix} -vvv --test-path src %endif