Skip to content

Commit

Permalink
Add tests for minimal dependencies.
Browse files Browse the repository at this point in the history
Add `copy` extra to include the `zope.copy` dependency.

Fixes #5.
  • Loading branch information
icemac committed Jan 30, 2025
1 parent 976ffa1 commit bbe277f
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 5 deletions.
16 changes: 15 additions & 1 deletion .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
[meta]
template = "pure-python"
commit-id = "75c6251b"
commit-id = "0754ed06"

[python]
with-macos = false
Expand All @@ -14,6 +14,20 @@ with-sphinx-doctests = true

[tox]
use-flake8 = true
additional-envlist = [
"py311-minimal",
"py311-component",
]
testenv-additional = [
"",
"[testenv:py311-minimal]",
"extras = test-minimal",
"commands = zope-testrunner --test-path=src {posargs:-vc}",
"",
"[testenv:py311-component]",
"extras = test-component",
"commands = zope-testrunner --test-path=src {posargs:-vc}",
]

[coverage]
fail-under = 100
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

- Drop support for Python 3.7, 3.8.

- Add tests for minimal dependencies.

- Add ``copy`` extra to include the ``zope.copy`` dependency.

5.0 (2023-05-25)
================
Expand Down
17 changes: 14 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]

Expand All @@ -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',
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions src/zope/location/testing.py
Original file line number Diff line number Diff line change
@@ -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
12 changes: 11 additions & 1 deletion src/zope/location/tests/test_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/zope/location/tests/test_pickling.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
##############################################################################
import unittest

from zope.location.testing import skipUnlessImportable


@skipUnlessImportable('zope.copy')
class LocationCopyHookTests(unittest.TestCase):

def _getTargetClass(self):
Expand Down
10 changes: 10 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ envlist =
pypy3
docs
coverage
py311-minimal
py311-component

[testenv]
usedevelop = true
Expand All @@ -27,6 +29,14 @@ extras =
test
docs

[testenv:py311-minimal]
extras = test-minimal
commands = zope-testrunner --test-path=src {posargs:-vc}

[testenv:py311-component]
extras = test-component
commands = zope-testrunner --test-path=src {posargs:-vc}

[testenv:setuptools-latest]
basepython = python3
deps =
Expand Down

0 comments on commit bbe277f

Please sign in to comment.