From e93ff5f4b202354e3b7be46fbabfd5ec2fcdbca1 Mon Sep 17 00:00:00 2001 From: Jens Vagelpohl Date: Mon, 16 Sep 2024 08:34:04 +0200 Subject: [PATCH] - update to latest meta/config and declare final Python 3.13 support. --- .coveragerc | 30 ---- .github/workflows/tests.yml | 44 +----- .manylinux-install.sh | 13 +- .meta.toml | 4 +- .pre-commit-config.yaml | 4 + CHANGES.rst | 2 +- MANIFEST.in | 1 - pyproject.toml | 26 ++++ src/zope/security/tests/test_adapter.py | 32 ++--- src/zope/security/tests/test_checker.py | 26 ++-- src/zope/security/tests/test_decorator.py | 8 +- src/zope/security/tests/test_management.py | 16 +-- src/zope/security/tests/test_metaconfigure.py | 130 +++++++++--------- src/zope/security/tests/test_permission.py | 4 +- src/zope/security/tests/test_protectclass.py | 18 +-- src/zope/security/tests/test_proxy.py | 16 +-- .../security/tests/test_simpleinteraction.py | 8 +- .../security/tests/test_simplepolicies.py | 12 +- src/zope/security/tests/test_zcml.py | 10 +- tox.ini | 18 +-- 20 files changed, 192 insertions(+), 230 deletions(-) delete mode 100644 .coveragerc create mode 100644 pyproject.toml diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 89bc080..0000000 --- a/.coveragerc +++ /dev/null @@ -1,30 +0,0 @@ -# Generated from: -# https://github.com/zopefoundation/meta/tree/master/config/c-code -[run] -source = zope.security -# New in 5.0; required for the GHA coveralls submission. -relative_files = True -branch = true - -[paths] -source = - src/ - .tox/*/lib/python*/site-packages/ - .tox/pypy*/site-packages/ - -[report] -show_missing = true -precision = 2 -ignore_errors = True -exclude_lines = - except ImportError: - if __name__ == '__main__': - pragma: no cover - pragma: nocover - raise AssertionError - raise NotImplementedError - raise unittest.Skip - self.fail\( - -[html] -directory = parts/htmlcov diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8fe9fcc..9fb059a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -152,17 +152,10 @@ jobs: restore-keys: | ${{ runner.os }}-pip- - - name: Install Build Dependencies (3.13) - if: matrix.python-version == '3.13' - run: | - pip install -U pip - pip install -U --pre cffi - pip install -U "setuptools<69" wheel twine - name: Install Build Dependencies - if: matrix.python-version != '3.13' run: | pip install -U pip - pip install -U "setuptools<69" wheel twine + pip install -U "setuptools <74" wheel twine pip install cffi pip install -U zope.proxy @@ -202,15 +195,7 @@ jobs: python setup.py build_ext -i python setup.py bdist_wheel - - name: Install zope.security and dependencies (3.13) - if: matrix.python-version == '3.13' - run: | - # Install to collect dependencies into the (pip) cache. - # Use "--pre" here because dependencies with support for this future - # Python release may only be available as pre-releases - pip install --pre .[test] - name: Install zope.security and dependencies - if: matrix.python-version != '3.13' run: | # Install to collect dependencies into the (pip) cache. pip install .[test] @@ -253,7 +238,6 @@ jobs: && startsWith(github.ref, 'refs/tags') && !startsWith(runner.os, 'Linux') && !startsWith(matrix.python-version, 'pypy') - && !startsWith(matrix.python-version, '3.13') env: TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} run: | @@ -327,32 +311,16 @@ jobs: with: name: zope.security-${{ runner.os }}-${{ matrix.python-version }}.whl path: dist/ - - name: Install zope.security ${{ matrix.python-version }} - if: matrix.python-version == '3.13' - run: | - pip install -U --pre cffi - pip install -U wheel "setuptools<69" - # coverage might have a wheel on PyPI for a future python version which is - # not ABI compatible with the current one, so build it from sdist: - pip install -U --no-binary :all: coverage - # Unzip into src/ so that testrunner can find the .so files - # when we ask it to load tests from that directory. This - # might also save some build time? - unzip -n dist/zope.security-*whl -d src - # Use "--pre" here because dependencies with support for this future - # Python release may only be available as pre-releases - pip install --pre -U -e .[test] - name: Install zope.security - if: matrix.python-version != '3.13' run: | - pip install -U wheel "setuptools<69" - pip install -U coverage + pip install -U wheel "setuptools <74" + pip install -U coverage[toml] pip install -U 'cffi; platform_python_implementation == "CPython"' # Unzip into src/ so that testrunner can find the .so files # when we ask it to load tests from that directory. This # might also save some build time? unzip -n dist/zope.security-*whl -d src - pip install -U -e .[test] + pip install -e .[test] - name: Run tests with C extensions if: ${{ !startsWith(matrix.python-version, 'pypy') }} run: | @@ -443,7 +411,7 @@ jobs: - name: Install zope.security run: | pip install -U wheel - pip install -U coverage + pip install -U coverage[toml] pip install -U "`ls dist/zope.security-*.whl`[docs]" - name: Build docs env: @@ -539,8 +507,6 @@ jobs: name: manylinux_${{ matrix.image }}_wheels.zip - name: Restore pip cache permissions run: sudo chown -R $(whoami) ${{ steps.pip-cache-default.outputs.dir }} - - name: Prevent publishing wheels for unreleased Python versions - run: VER=$(echo '3.13' | tr -d .) && ls -al wheelhouse && sudo rm -f wheelhouse/*-cp${VER}*.whl && ls -al wheelhouse - name: Publish package to PyPI uses: pypa/gh-action-pypi-publish@release/v1 if: > diff --git a/.manylinux-install.sh b/.manylinux-install.sh index 46cd34d..7dd68b6 100755 --- a/.manylinux-install.sh +++ b/.manylinux-install.sh @@ -28,12 +28,12 @@ yum -y install libffi-devel tox_env_map() { case $1 in - *"cp313"*) echo 'py313';; *"cp38"*) echo 'py38';; *"cp39"*) echo 'py39';; *"cp310"*) echo 'py310';; *"cp311"*) echo 'py311';; *"cp312"*) echo 'py312';; + *"cp313"*) echo 'py313';; *) echo 'py';; esac } @@ -41,19 +41,14 @@ tox_env_map() { # Compile wheels for PYBIN in /opt/python/*/bin; do if \ - [[ "${PYBIN}" == *"cp313/"* ]] || \ [[ "${PYBIN}" == *"cp311/"* ]] || \ [[ "${PYBIN}" == *"cp312/"* ]] || \ + [[ "${PYBIN}" == *"cp313/"* ]] || \ [[ "${PYBIN}" == *"cp38/"* ]] || \ [[ "${PYBIN}" == *"cp39/"* ]] || \ [[ "${PYBIN}" == *"cp310/"* ]] ; then - if [[ "${PYBIN}" == *"cp313/"* ]] ; then - "${PYBIN}/pip" install --pre -e /io/ - "${PYBIN}/pip" wheel /io/ --pre -w wheelhouse/ - else - "${PYBIN}/pip" install -e /io/ - "${PYBIN}/pip" wheel /io/ -w wheelhouse/ - fi + "${PYBIN}/pip" install -e /io/ + "${PYBIN}/pip" wheel /io/ -w wheelhouse/ if [ `uname -m` == 'aarch64' ]; then cd /io/ ${PYBIN}/pip install tox diff --git a/.meta.toml b/.meta.toml index d5e2f5b..bd1e183 100644 --- a/.meta.toml +++ b/.meta.toml @@ -2,12 +2,12 @@ # https://github.com/zopefoundation/meta/tree/master/config/c-code [meta] template = "c-code" -commit-id = "023baad4" +commit-id = "4f5c47bd" [python] with-windows = true with-pypy = true -with-future-python = true +with-future-python = false with-docs = true with-sphinx-doctests = true with-macos = false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7b83bb8..b5d6386 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,6 +16,10 @@ repos: hooks: - id: pyupgrade args: [--py38-plus] + - repo: https://github.com/isidentical/teyit + rev: 0.4.3 + hooks: + - id: teyit - repo: https://github.com/PyCQA/flake8 rev: "7.1.1" hooks: diff --git a/CHANGES.rst b/CHANGES.rst index 06523fd..3272978 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,7 +5,7 @@ 7.2 (unreleased) ---------------- -- Nothing changed yet. +- Declare final support for Python 3.13. 7.1 (2024-08-16) diff --git a/MANIFEST.in b/MANIFEST.in index 7b485db..d9431f5 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -6,7 +6,6 @@ include *.txt include buildout.cfg include tox.ini include .pre-commit-config.yaml -include .coveragerc recursive-include docs *.py recursive-include docs *.rst diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..0797dba --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,26 @@ +# +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/c-code + +[build-system] +requires = ["setuptools<74"] +build-backend = "setuptools.build_meta" + +[tool.coverage] +[tool.coverage.run] +branch = true +source = ["zope.security"] +relative_files = true + +[tool.coverage.report] +fail_under = 99.5 +precision = 2 +ignore_errors = true +show_missing = true +exclude_lines = ["pragma: no cover", "pragma: nocover", "except ImportError:", "raise NotImplementedError", "if __name__ == '__main__':", "self.fail", "raise AssertionError", "raise unittest.Skip"] + +[tool.coverage.html] +directory = "parts/htmlcov" + +[tool.coverage.paths] +source = ["src/", ".tox/*/lib/python*/site-packages/", ".tox/pypy*/site-packages/"] diff --git a/src/zope/security/tests/test_adapter.py b/src/zope/security/tests/test_adapter.py index 6fd274c..5e7ab5a 100644 --- a/src/zope/security/tests/test_adapter.py +++ b/src/zope/security/tests/test_adapter.py @@ -35,7 +35,7 @@ class _NotAdapter: adapter = _NotAdapter() parent = object() returned = self._callFUT(adapter, parent) - self.assertTrue(isinstance(returned, LocationProxy)) + self.assertIsInstance(returned, LocationProxy) self.assertIs(getProxiedObject(returned), adapter) self.assertIs(returned.__parent__, parent) @@ -158,7 +158,7 @@ class _NotAdapter: proxy = ProxyFactory(adapter) before = factory.__dict__.copy() returned = ltaf(proxy) - self.assertFalse(returned is factory) + self.assertIsNot(returned, factory) ploc = removeSecurityProxy(returned) self.assertIs(ploc.__parent__, adapter) unwrapped = getProxiedObject(ploc) @@ -181,7 +181,7 @@ class _NotAdapter: proxy = ProxyFactory(adapter) before = factory.__dict__.copy() returned = ltaf(proxy, extra) - self.assertFalse(returned is factory) + self.assertIsNot(returned, factory) ploc = removeSecurityProxy(returned) self.assertIs(ploc.__parent__, adapter) unwrapped = getProxiedObject(ploc) @@ -207,7 +207,7 @@ class _Extra: proxy = ProxyFactory(extra) before = factory.__dict__.copy() returned = ltaf(adapter, proxy) - self.assertFalse(returned is factory) + self.assertIsNot(returned, factory) ploc = removeSecurityProxy(returned) self.assertIs(ploc.__parent__, adapter) unwrapped = getProxiedObject(ploc) @@ -233,7 +233,7 @@ class _Adapter: before = {k: v for k, v in factory.__dict__.items() if k not in ('_called_with', '__parent__')} returned = ltaf(proxy) - self.assertFalse(returned is factory) + self.assertIsNot(returned, factory) ploc = removeSecurityProxy(returned) self.assertIs(ploc.__parent__, adapter) unwrapped = getObject(ploc) @@ -261,7 +261,7 @@ class _Adapter: before = {k: v for k, v in factory.__dict__.items() if k not in ('_called_with', '__parent__')} returned = ltaf(proxy) - self.assertFalse(returned is factory) + self.assertIsNot(returned, factory) ploc = removeSecurityProxy(returned) self.assertIs(ploc.__parent__, parent) unwrapped = getObject(ploc) @@ -303,9 +303,9 @@ class _NotAdapter: proxy = ProxyFactory(adapter) before = factory.__dict__.copy() returned = ltaf(proxy) - self.assertFalse(returned is factory) + self.assertIsNot(returned, factory) unwrapped = removeSecurityProxy(returned) - self.assertTrue('__parent__' not in unwrapped.__dict__) + self.assertNotIn('__parent__', unwrapped.__dict__) self.assertIs(unwrapped, factory) after = {k: v for k, v in unwrapped.__dict__.items() if k not in ('_called_with',)} @@ -325,9 +325,9 @@ class _NotAdapter: proxy = ProxyFactory(adapter) before = factory.__dict__.copy() returned = ltaf(proxy, extra) - self.assertFalse(returned is factory) + self.assertIsNot(returned, factory) unwrapped = removeSecurityProxy(returned) - self.assertTrue('__parent__' not in unwrapped.__dict__) + self.assertNotIn('__parent__', unwrapped.__dict__) self.assertIs(unwrapped, factory) after = {k: v for k, v in unwrapped.__dict__.items() if k not in ('_called_with',)} @@ -350,9 +350,9 @@ class _Extra: proxy = ProxyFactory(extra) before = factory.__dict__.copy() returned = ltaf(adapter, proxy) - self.assertFalse(returned is factory) + self.assertIsNot(returned, factory) unwrapped = removeSecurityProxy(returned) - self.assertTrue('__parent__' not in unwrapped.__dict__) + self.assertNotIn('__parent__', unwrapped.__dict__) self.assertIs(unwrapped, factory) after = {k: v for k, v in unwrapped.__dict__.items() if k not in ('_called_with',)} @@ -374,7 +374,7 @@ class _Adapter: before = {k: v for k, v in factory.__dict__.items() if k not in ('_called_with', '__parent__')} returned = ltaf(proxy) - self.assertFalse(returned is factory) + self.assertIsNot(returned, factory) unwrapped = removeSecurityProxy(returned) self.assertIs(unwrapped.__parent__, adapter) self.assertIs(unwrapped, factory) @@ -399,7 +399,7 @@ class _Adapter: before = {k: v for k, v in factory.__dict__.items() if k not in ('_called_with', '__parent__')} returned = ltaf(proxy) - self.assertFalse(returned is factory) + self.assertIsNot(returned, factory) unwrapped = removeSecurityProxy(returned) self.assertIs(unwrapped.__parent__, parent) self.assertIs(unwrapped, factory) @@ -445,7 +445,7 @@ class _NotAdapter: adapter = _NotAdapter() before = factory.__dict__.copy() returned = ltaf(adapter) - self.assertFalse(returned is factory) + self.assertIsNot(returned, factory) unwrapped = getProxiedObject(returned) self.assertIs(unwrapped, factory) after = {k: v for k, v in returned.__dict__.items() @@ -463,7 +463,7 @@ class _NotAdapter: extra = object() before = factory.__dict__.copy() returned = ltaf(adapter, extra) - self.assertFalse(returned is factory) + self.assertIsNot(returned, factory) unwrapped = getProxiedObject(returned) self.assertIs(unwrapped, factory) after = {k: v for k, v in returned.__dict__.items() diff --git a/src/zope/security/tests/test_checker.py b/src/zope/security/tests/test_checker.py index 3167a1f..4778c28 100644 --- a/src/zope/security/tests/test_checker.py +++ b/src/zope/security/tests/test_checker.py @@ -71,7 +71,7 @@ def test_w_explicit_checker(self): def _check(*x): raise AssertionError("Never called") returned = self._callFUT(obj, _check) - self.assertFalse(returned is obj) + self.assertIsNot(returned, obj) self.assertIs(getChecker(returned), _check) def test_no_checker_no_dunder_no_select(self): @@ -88,7 +88,7 @@ class _WithChecker: __Security_checker__ = _check obj = _WithChecker() returned = self._callFUT(obj) - self.assertFalse(returned is obj) + self.assertIsNot(returned, obj) self.assertIs(getObject(returned), obj) self.assertIs(getChecker(returned), _check) @@ -109,7 +109,7 @@ def _check(*args): _checkers[_Obj] = _check try: returned = self._callFUT(obj) - self.assertFalse(returned is obj) + self.assertIsNot(returned, obj) self.assertIs(getObject(returned), obj) self.assertIs(getChecker(returned), _checker) finally: @@ -386,7 +386,7 @@ class _WithChecker: obj = _WithChecker() checker = self._makeOne() returned = checker.proxy(obj) - self.assertFalse(returned is obj) + self.assertIsNot(returned, obj) self.assertIs(getObject(returned), obj) self.assertIs(getChecker(returned), _check) @@ -408,7 +408,7 @@ def _check(*args): try: checker = self._makeOne() returned = checker.proxy(obj) - self.assertFalse(returned is obj) + self.assertIsNot(returned, obj) self.assertIs(getObject(returned), obj) self.assertIs(getChecker(returned), _checker) finally: @@ -427,10 +427,10 @@ def test_Decimal_operations(self): proxy = Proxy(value, checker) self.assertTrue(proxy) - self.assertTrue(proxy < Decimal('2')) - self.assertTrue(proxy == Decimal('1.1')) - self.assertTrue(proxy > Decimal('1')) - self.assertTrue(proxy != Decimal('1')) + self.assertLess(proxy, Decimal('2')) + self.assertEqual(proxy, Decimal('1.1')) + self.assertGreater(proxy, Decimal('1')) + self.assertNotEqual(proxy, Decimal('1')) self.assertEqual(-proxy, Decimal('-1.1')) self.assertEqual(proxy + Decimal('1.1'), Decimal('2.2')) self.assertEqual(Decimal('1.1') + proxy, Decimal('2.2')) @@ -1195,7 +1195,7 @@ class Foo: pass _checkers[Foo] = object() self._callFUT(Foo) - self.assertFalse(Foo in _checkers) + self.assertNotIn(Foo, _checkers) class TestCombinedChecker(QuietWatchingChecker, @@ -1693,7 +1693,7 @@ def _get_old_class_type(self): # Py3 has no ClassType and no old-style classes import types old_type = getattr(types, 'ClassType', type) - self.assertTrue(old_type is type) + self.assertIs(old_type, type) return old_type def _makeSecurityPolicy(self): @@ -2348,8 +2348,8 @@ class Foo: checker = object() BasicTypes[Foo] = checker del BasicTypes[Foo] - self.assertFalse(Foo in BasicTypes) - self.assertFalse(Foo in _checkers) + self.assertNotIn(Foo, BasicTypes) + self.assertNotIn(Foo, _checkers) def test_clear(self): from zope.security.checker import BasicTypes diff --git a/src/zope/security/tests/test_decorator.py b/src/zope/security/tests/test_decorator.py index c56a996..d9c0ac5 100644 --- a/src/zope/security/tests/test_decorator.py +++ b/src/zope/security/tests/test_decorator.py @@ -85,7 +85,7 @@ class Wrapper(ProxyBase): wrapperChecker.check(foo, 'b') # no raise checker = wrapper.__Security_checker__ - self.assertTrue(isinstance(checker, CombinedChecker)) + self.assertIsInstance(checker, CombinedChecker) checker.check(wrapper, 'a') # no raise checker.check(wrapper, 'b') # no raise @@ -107,7 +107,7 @@ class Wrapper(ProxyBase): wrapperChecker = NamesChecker(['b']) # b is public defineChecker(Wrapper, wrapperChecker) wrapper = Wrapper(foo) - self.assertTrue(wrapper.__Security_checker__ is wrapperChecker) + self.assertIs(wrapper.__Security_checker__, wrapperChecker) def test_only_object_has_checker(self): from zope.proxy import ProxyBase @@ -127,7 +127,7 @@ class Wrapper(ProxyBase): __Security_checker__ = self._makeOne() defineChecker(Wrapper, NoProxy) wrapper = Wrapper(foo) - self.assertTrue(wrapper.__Security_checker__ is fooChecker) + self.assertIs(wrapper.__Security_checker__, fooChecker) def test_both_wrapper_and_object_have_checkers_security_proxied(self): from zope.proxy import ProxyBase @@ -152,7 +152,7 @@ class Wrapper(ProxyBase): w_sec = Wrapper(f_sec) checker = w_sec.__Security_checker__ - self.assertTrue(isinstance(checker, CombinedChecker)) + self.assertIsInstance(checker, CombinedChecker) checker.check(w_sec, 'a') # no raise checker.check(w_sec, 'b') # no raise diff --git a/src/zope/security/tests/test_management.py b/src/zope/security/tests/test_management.py index 7cc7e3b..b4a5558 100644 --- a/src/zope/security/tests/test_management.py +++ b/src/zope/security/tests/test_management.py @@ -47,7 +47,7 @@ def test_securityPolicy(self): policy = PermissiveSecurityPolicy setSecurityPolicy(policy) - self.assertTrue(getSecurityPolicy() is policy) + self.assertIs(getSecurityPolicy(), policy) def test_getInteraction_none_present(self): from zope.security.interfaces import NoInteraction @@ -63,7 +63,7 @@ def test_newInteraction(self): from zope.security.management import queryInteraction newInteraction() interaction = queryInteraction() - self.assertTrue(interaction is not None) + self.assertIsNotNone(interaction) def test_newInteraction_repeated_without_end(self): from zope.security.management import ExistingInteraction @@ -99,16 +99,16 @@ def test_restoreInteraction_after_end(self): interaction = queryInteraction() endInteraction() restoreInteraction() - self.assertTrue(interaction is queryInteraction()) + self.assertIs(interaction, queryInteraction()) def test_restoreInteraction_after_new(self): from zope.security.management import newInteraction from zope.security.management import queryInteraction from zope.security.management import restoreInteraction newInteraction() - self.assertTrue(queryInteraction() is not None) + self.assertIsNotNone(queryInteraction()) restoreInteraction() # restore to no interaction - self.assertTrue(queryInteraction() is None) + self.assertIsNone(queryInteraction()) def test_restoreInteraction_after_neither(self): from zope.security._definitions import thread_local @@ -123,7 +123,7 @@ def test_restoreInteraction_after_neither(self): except AttributeError: pass restoreInteraction() - self.assertTrue(queryInteraction() is None) + self.assertIsNone(queryInteraction()) def test_checkPermission_w_no_interaction(self): from zope.security.interfaces import NoInteraction @@ -143,8 +143,8 @@ def test_checkPermission_w_interaction(self): class PolicyStub: def checkPermission(s, p, o,): - self.assertTrue(p is permission) - self.assertTrue(o is obj) + self.assertIs(p, permission) + self.assertIs(o, obj) self.assertTrue(s is queryInteraction() or s is interaction) return s is interaction diff --git a/src/zope/security/tests/test_metaconfigure.py b/src/zope/security/tests/test_metaconfigure.py index 76471bd..6f83408 100644 --- a/src/zope/security/tests/test_metaconfigure.py +++ b/src/zope/security/tests/test_metaconfigure.py @@ -63,10 +63,10 @@ class IFoo(Interface): self.assertEqual(len(context._actions), 2) self.assertEqual(context._actions[0]['discriminator'][:2], ('ContentDirective', Foo, )) # 3rd is object() - self.assertTrue(context._actions[0]['callable'] is classImplements) + self.assertIs(context._actions[0]['callable'], classImplements) self.assertEqual(context._actions[0]['args'], (Foo, IFoo)) - self.assertTrue(context._actions[1]['discriminator'] is None) - self.assertTrue(context._actions[1]['callable'] is provideInterface) + self.assertIsNone(context._actions[1]['discriminator']) + self.assertIs(context._actions[1]['callable'], provideInterface) self.assertEqual(context._actions[1]['args'], ('zope.security.tests.test_metaconfigure.IFoo', IFoo)) @@ -86,18 +86,18 @@ class IBar(Interface): self.assertEqual(len(context._actions), 4) self.assertEqual(context._actions[0]['discriminator'][:2], ('ContentDirective', Foo, )) # 3rd is object() - self.assertTrue(context._actions[0]['callable'] is classImplements) + self.assertIs(context._actions[0]['callable'], classImplements) self.assertEqual(context._actions[0]['args'], (Foo, IFoo)) - self.assertTrue(context._actions[1]['discriminator'] is None) - self.assertTrue(context._actions[1]['callable'] is provideInterface) + self.assertIsNone(context._actions[1]['discriminator']) + self.assertIs(context._actions[1]['callable'], provideInterface) self.assertEqual(context._actions[1]['args'], ('zope.security.tests.test_metaconfigure.IFoo', IFoo)) self.assertEqual(context._actions[2]['discriminator'][:2], ('ContentDirective', Foo, )) # 3rd is object() - self.assertTrue(context._actions[2]['callable'] is classImplements) + self.assertIs(context._actions[2]['callable'], classImplements) self.assertEqual(context._actions[2]['args'], (Foo, IBar)) - self.assertTrue(context._actions[3]['discriminator'] is None) - self.assertTrue(context._actions[3]['callable'] is provideInterface) + self.assertIsNone(context._actions[3]['discriminator']) + self.assertIs(context._actions[3]['callable'], provideInterface) self.assertEqual(context._actions[3]['args'], ('zope.security.tests.test_metaconfigure.IBar', IBar)) @@ -112,7 +112,7 @@ class Bar: self.assertEqual(len(context._actions), 1) self.assertEqual(context._actions[0]['discriminator'][:2], ('mimic', Foo, )) # 3rd is object() - self.assertTrue(context._actions[0]['callable'] is protectLikeUnto) + self.assertIs(context._actions[0]['callable'], protectLikeUnto) self.assertEqual(context._actions[0]['args'], (Foo, Bar)) def test_require_only_permission(self): @@ -145,14 +145,14 @@ class IFoo(Interface): self.assertEqual(len(context._actions), 3) self.assertEqual(context._actions[0]['discriminator'], ('protectName', Foo, 'bar')) - self.assertTrue(context._actions[0]['callable'] is protectName) + self.assertIs(context._actions[0]['callable'], protectName) self.assertEqual(context._actions[0]['args'], (Foo, 'bar', 'testing')) self.assertEqual(context._actions[1]['discriminator'], ('protectName', Foo, 'baz')) - self.assertTrue(context._actions[1]['callable'] is protectName) + self.assertIs(context._actions[1]['callable'], protectName) self.assertEqual(context._actions[1]['args'], (Foo, 'baz', 'testing')) - self.assertTrue(context._actions[2]['discriminator'] is None) - self.assertTrue(context._actions[2]['callable'] is provideInterface) + self.assertIsNone(context._actions[2]['discriminator']) + self.assertIs(context._actions[2]['callable'], provideInterface) self.assertEqual(context._actions[2]['args'], ('zope.security.tests.test_metaconfigure.IFoo', IFoo)) @@ -175,18 +175,18 @@ class IBar(Interface): self.assertEqual(len(context._actions), 4) self.assertEqual(context._actions[0]['discriminator'], ('protectName', Foo, 'bar')) - self.assertTrue(context._actions[0]['callable'] is protectName) + self.assertIs(context._actions[0]['callable'], protectName) self.assertEqual(context._actions[0]['args'], (Foo, 'bar', 'testing')) - self.assertTrue(context._actions[1]['discriminator'] is None) - self.assertTrue(context._actions[1]['callable'] is provideInterface) + self.assertIsNone(context._actions[1]['discriminator']) + self.assertIs(context._actions[1]['callable'], provideInterface) self.assertEqual(context._actions[1]['args'], ('zope.security.tests.test_metaconfigure.IFoo', IFoo)) self.assertEqual(context._actions[2]['discriminator'], ('protectName', Foo, 'baz')) - self.assertTrue(context._actions[2]['callable'] is protectName) + self.assertIs(context._actions[2]['callable'], protectName) self.assertEqual(context._actions[2]['args'], (Foo, 'baz', 'testing')) - self.assertTrue(context._actions[3]['discriminator'] is None) - self.assertTrue(context._actions[3]['callable'] is provideInterface) + self.assertIsNone(context._actions[3]['discriminator']) + self.assertIs(context._actions[3]['callable'], provideInterface) self.assertEqual(context._actions[3]['args'], ('zope.security.tests.test_metaconfigure.IBar', IBar)) @@ -199,11 +199,11 @@ def test_require_w_attributes(self): self.assertEqual(len(context._actions), 2) self.assertEqual(context._actions[0]['discriminator'], ('protectName', Foo, 'bar')) - self.assertTrue(context._actions[0]['callable'] is protectName) + self.assertIs(context._actions[0]['callable'], protectName) self.assertEqual(context._actions[0]['args'], (Foo, 'bar', 'testing')) self.assertEqual(context._actions[1]['discriminator'], ('protectName', Foo, 'baz')) - self.assertTrue(context._actions[1]['callable'] is protectName) + self.assertIs(context._actions[1]['callable'], protectName) self.assertEqual(context._actions[1]['args'], (Foo, 'baz', 'testing')) def test_require_w_set_attributes(self): @@ -215,11 +215,11 @@ def test_require_w_set_attributes(self): self.assertEqual(len(context._actions), 2) self.assertEqual(context._actions[0]['discriminator'], ('protectSetAttribute', Foo, 'bar')) - self.assertTrue(context._actions[0]['callable'] is protectSetAttribute) + self.assertIs(context._actions[0]['callable'], protectSetAttribute) self.assertEqual(context._actions[0]['args'], (Foo, 'bar', 'testing')) self.assertEqual(context._actions[1]['discriminator'], ('protectSetAttribute', Foo, 'baz')) - self.assertTrue(context._actions[1]['callable'] is protectSetAttribute) + self.assertIs(context._actions[1]['callable'], protectSetAttribute) self.assertEqual(context._actions[1]['args'], (Foo, 'baz', 'testing')) def test_require_w_set_schema_normal_fields(self): @@ -238,14 +238,14 @@ class IFoo(Interface): self.assertEqual(len(context._actions), 3) self.assertEqual(context._actions[0]['discriminator'], ('protectSetAttribute', Foo, 'bar')) - self.assertTrue(context._actions[0]['callable'] is protectSetAttribute) + self.assertIs(context._actions[0]['callable'], protectSetAttribute) self.assertEqual(context._actions[0]['args'], (Foo, 'bar', 'testing')) self.assertEqual(context._actions[1]['discriminator'], ('protectSetAttribute', Foo, 'baz')) - self.assertTrue(context._actions[1]['callable'] is protectSetAttribute) + self.assertIs(context._actions[1]['callable'], protectSetAttribute) self.assertEqual(context._actions[1]['args'], (Foo, 'baz', 'testing')) - self.assertTrue(context._actions[2]['discriminator'] is None) - self.assertTrue(context._actions[2]['callable'] is provideInterface) + self.assertIsNone(context._actions[2]['discriminator']) + self.assertIs(context._actions[2]['callable'], provideInterface) self.assertEqual(context._actions[2]['args'], ('zope.security.tests.test_metaconfigure.IFoo', IFoo)) @@ -260,8 +260,8 @@ class IFoo(Interface): directive = self._makeOne(context, Foo) directive.require(context, permission='testing', set_schema=[IFoo]) self.assertEqual(len(context._actions), 1) - self.assertTrue(context._actions[0]['discriminator'] is None) - self.assertTrue(context._actions[0]['callable'] is provideInterface) + self.assertIsNone(context._actions[0]['discriminator']) + self.assertIs(context._actions[0]['callable'], provideInterface) self.assertEqual(context._actions[0]['args'], ('zope.security.tests.test_metaconfigure.IFoo', IFoo)) @@ -276,8 +276,8 @@ class IFoo(Interface): directive = self._makeOne(context, Foo) directive.require(context, permission='testing', set_schema=[IFoo]) self.assertEqual(len(context._actions), 1) - self.assertTrue(context._actions[0]['discriminator'] is None) - self.assertTrue(context._actions[0]['callable'] is provideInterface) + self.assertIsNone(context._actions[0]['discriminator']) + self.assertIs(context._actions[0]['callable'], provideInterface) self.assertEqual(context._actions[0]['args'], ('zope.security.tests.test_metaconfigure.IFoo', IFoo)) @@ -303,16 +303,16 @@ class IFoo(Interface): self.assertEqual(len(context._actions), 3) self.assertEqual(context._actions[0]['discriminator'], ('protectName', Foo, 'bar')) - self.assertTrue(context._actions[0]['callable'] is protectName) + self.assertIs(context._actions[0]['callable'], protectName) self.assertEqual(context._actions[0]['args'], (Foo, 'bar', zope_Public)) self.assertEqual(context._actions[1]['discriminator'], ('protectName', Foo, 'baz')) - self.assertTrue(context._actions[1]['callable'] is protectName) + self.assertIs(context._actions[1]['callable'], protectName) self.assertEqual(context._actions[1]['args'], (Foo, 'baz', zope_Public)) - self.assertTrue(context._actions[2]['discriminator'] is None) - self.assertTrue(context._actions[2]['callable'] is provideInterface) + self.assertIsNone(context._actions[2]['discriminator']) + self.assertIs(context._actions[2]['callable'], provideInterface) self.assertEqual(context._actions[2]['args'], ('zope.security.tests.test_metaconfigure.IFoo', IFoo)) @@ -334,20 +334,20 @@ class IBar(Interface): self.assertEqual(len(context._actions), 4) self.assertEqual(context._actions[0]['discriminator'], ('protectName', Foo, 'bar')) - self.assertTrue(context._actions[0]['callable'] is protectName) + self.assertIs(context._actions[0]['callable'], protectName) self.assertEqual(context._actions[0]['args'], (Foo, 'bar', zope_Public)) - self.assertTrue(context._actions[1]['discriminator'] is None) - self.assertTrue(context._actions[1]['callable'] is provideInterface) + self.assertIsNone(context._actions[1]['discriminator']) + self.assertIs(context._actions[1]['callable'], provideInterface) self.assertEqual(context._actions[1]['args'], ('zope.security.tests.test_metaconfigure.IFoo', IFoo)) self.assertEqual(context._actions[2]['discriminator'], ('protectName', Foo, 'baz')) - self.assertTrue(context._actions[2]['callable'] is protectName) + self.assertIs(context._actions[2]['callable'], protectName) self.assertEqual(context._actions[2]['args'], (Foo, 'baz', zope_Public)) - self.assertTrue(context._actions[3]['discriminator'] is None) - self.assertTrue(context._actions[3]['callable'] is provideInterface) + self.assertIsNone(context._actions[3]['discriminator']) + self.assertIs(context._actions[3]['callable'], provideInterface) self.assertEqual(context._actions[3]['args'], ('zope.security.tests.test_metaconfigure.IBar', IBar)) @@ -359,12 +359,12 @@ def test_allow_w_attributes(self): self.assertEqual(len(context._actions), 2) self.assertEqual(context._actions[0]['discriminator'], ('protectName', Foo, 'bar')) - self.assertTrue(context._actions[0]['callable'] is protectName) + self.assertIs(context._actions[0]['callable'], protectName) self.assertEqual(context._actions[0]['args'], (Foo, 'bar', zope_Public)) self.assertEqual(context._actions[1]['discriminator'], ('protectName', Foo, 'baz')) - self.assertTrue(context._actions[1]['callable'] is protectName) + self.assertIs(context._actions[1]['callable'], protectName) self.assertEqual(context._actions[1]['args'], (Foo, 'baz', zope_Public)) @@ -385,7 +385,7 @@ def test_factory_wo_explicit_id(self): self.assertEqual(context._actions[0]['discriminator'], ('utility', IFactory, 'zope.security.tests.test_metaconfigure.Foo')) - self.assertTrue(context._actions[0]['callable'] is handler) + self.assertIs(context._actions[0]['callable'], handler) args = context._actions[0]['args'] self.assertEqual(args[0], 'registerUtility') factory = args[1] @@ -395,8 +395,8 @@ def test_factory_wo_explicit_id(self): self.assertEqual(args[2], IFactory) self.assertEqual(args[3], 'zope.security.tests.test_metaconfigure.Foo') self.assertEqual(args[4], 'INFO') - self.assertTrue(context._actions[1]['discriminator'] is None) - self.assertTrue(context._actions[1]['callable'] is provideInterface) + self.assertIsNone(context._actions[1]['discriminator']) + self.assertIs(context._actions[1]['callable'], provideInterface) self.assertEqual(context._actions[1]['args'], ('', IFactory)) def test_factory_w_explicit_id(self): @@ -410,7 +410,7 @@ def test_factory_w_explicit_id(self): self.assertEqual(len(context._actions), 2) self.assertEqual(context._actions[0]['discriminator'], ('utility', IFactory, 'test_id')) - self.assertTrue(context._actions[0]['callable'] is handler) + self.assertIs(context._actions[0]['callable'], handler) args = context._actions[0]['args'] self.assertEqual(args[0], 'registerUtility') factory = args[1] @@ -418,8 +418,8 @@ def test_factory_w_explicit_id(self): self.assertEqual(args[2], IFactory) self.assertEqual(args[3], 'test_id') self.assertEqual(args[4], 'INFO') - self.assertTrue(context._actions[1]['discriminator'] is None) - self.assertTrue(context._actions[1]['callable'] is provideInterface) + self.assertIsNone(context._actions[1]['discriminator']) + self.assertIs(context._actions[1]['callable'], provideInterface) self.assertEqual(context._actions[1]['args'], ('', IFactory)) @@ -447,7 +447,7 @@ def test_check_wo_existing_module_checker(self): perm = object() self._callFUT(module, 'name', perm) checker = _checkers[module] - self.assertTrue(checker.get_permissions['name'] is perm) + self.assertIs(checker.get_permissions['name'], perm) def test_check_w_existing_module_checker_zope_Public(self): from zope.security import tests as module @@ -457,8 +457,8 @@ def test_check_w_existing_module_checker_zope_Public(self): before = _checkers[module] = Checker({'other': CheckerPublic}) self._callFUT(module, 'name', zope_Public) checker = _checkers[module] - self.assertTrue(checker is before) - self.assertTrue(checker.get_permissions['name'] is CheckerPublic) + self.assertIs(checker, before) + self.assertIs(checker.get_permissions['name'], CheckerPublic) class Test_allow(unittest.TestCase): @@ -496,13 +496,13 @@ def test_w_attributes(self): self.assertEqual(context._actions[0]['discriminator'], ('http://namespaces.zope.org/zope:module', 'testing', 'foo')) - self.assertTrue(context._actions[0]['callable'] is protectModule) + self.assertIs(context._actions[0]['callable'], protectModule) self.assertEqual(context._actions[0]['args'], ('testing', 'foo', zope_Public)) self.assertEqual(context._actions[1]['discriminator'], ('http://namespaces.zope.org/zope:module', 'testing', 'bar')) - self.assertTrue(context._actions[1]['callable'] is protectModule) + self.assertIs(context._actions[1]['callable'], protectModule) self.assertEqual(context._actions[1]['args'], ('testing', 'bar', zope_Public)) @@ -521,7 +521,7 @@ class IFoo(Interface): self.assertEqual(context._actions[0]['discriminator'], ('http://namespaces.zope.org/zope:module', 'testing', 'bar')) - self.assertTrue(context._actions[0]['callable'] is protectModule) + self.assertIs(context._actions[0]['callable'], protectModule) self.assertEqual(context._actions[0]['args'], ('testing', 'bar', zope_Public)) @@ -542,19 +542,19 @@ class IFoo(Interface): self.assertEqual(context._actions[0]['discriminator'], ('http://namespaces.zope.org/zope:module', 'testing', 'foo')) - self.assertTrue(context._actions[0]['callable'] is protectModule) + self.assertIs(context._actions[0]['callable'], protectModule) self.assertEqual(context._actions[0]['args'], ('testing', 'foo', zope_Public)) self.assertEqual(context._actions[1]['discriminator'], ('http://namespaces.zope.org/zope:module', 'testing', 'bar')) - self.assertTrue(context._actions[1]['callable'] is protectModule) + self.assertIs(context._actions[1]['callable'], protectModule) self.assertEqual(context._actions[1]['args'], ('testing', 'bar', zope_Public)) self.assertEqual(context._actions[2]['discriminator'], ('http://namespaces.zope.org/zope:module', 'testing', 'baz')) - self.assertTrue(context._actions[2]['callable'] is protectModule) + self.assertIs(context._actions[2]['callable'], protectModule) self.assertEqual(context._actions[2]['args'], ('testing', 'baz', zope_Public)) @@ -597,13 +597,13 @@ def test_w_attributes(self): self.assertEqual(context._actions[0]['discriminator'], ('http://namespaces.zope.org/zope:module', 'testing', 'foo')) - self.assertTrue(context._actions[0]['callable'] is protectModule) + self.assertIs(context._actions[0]['callable'], protectModule) self.assertEqual(context._actions[0]['args'], ('testing', 'foo', perm)) self.assertEqual(context._actions[1]['discriminator'], ('http://namespaces.zope.org/zope:module', 'testing', 'bar')) - self.assertTrue(context._actions[1]['callable'] is protectModule) + self.assertIs(context._actions[1]['callable'], protectModule) self.assertEqual(context._actions[1]['args'], ('testing', 'bar', perm)) @@ -623,7 +623,7 @@ class IFoo(Interface): self.assertEqual(context._actions[0]['discriminator'], ('http://namespaces.zope.org/zope:module', 'testing', 'bar')) - self.assertTrue(context._actions[0]['callable'] is protectModule) + self.assertIs(context._actions[0]['callable'], protectModule) self.assertEqual(context._actions[0]['args'], ('testing', 'bar', perm)) @@ -645,19 +645,19 @@ class IFoo(Interface): self.assertEqual(context._actions[0]['discriminator'], ('http://namespaces.zope.org/zope:module', 'testing', 'foo')) - self.assertTrue(context._actions[0]['callable'] is protectModule) + self.assertIs(context._actions[0]['callable'], protectModule) self.assertEqual(context._actions[0]['args'], ('testing', 'foo', perm)) self.assertEqual(context._actions[1]['discriminator'], ('http://namespaces.zope.org/zope:module', 'testing', 'bar')) - self.assertTrue(context._actions[1]['callable'] is protectModule) + self.assertIs(context._actions[1]['callable'], protectModule) self.assertEqual(context._actions[1]['args'], ('testing', 'bar', perm)) self.assertEqual(context._actions[2]['discriminator'], ('http://namespaces.zope.org/zope:module', 'testing', 'baz')) - self.assertTrue(context._actions[2]['callable'] is protectModule) + self.assertIs(context._actions[2]['callable'], protectModule) self.assertEqual(context._actions[2]['args'], ('testing', 'baz', perm)) diff --git a/src/zope/security/tests/test_permission.py b/src/zope/security/tests/test_permission.py index 2326f37..71f53e7 100644 --- a/src/zope/security/tests/test_permission.py +++ b/src/zope/security/tests/test_permission.py @@ -120,7 +120,7 @@ def _callFUT(self): def test_empty(self): from zope.schema.vocabulary import SimpleVocabulary vocabulary = self._callFUT() - self.assertTrue(isinstance(vocabulary, SimpleVocabulary)) + self.assertIsInstance(vocabulary, SimpleVocabulary) self.assertEqual(list(vocabulary), []) def test_w_registration(self): @@ -175,7 +175,7 @@ def _callFUT(self): def test_empty(self): from zope.schema.vocabulary import SimpleVocabulary vocabulary = self._callFUT() - self.assertTrue(isinstance(vocabulary, SimpleVocabulary)) + self.assertIsInstance(vocabulary, SimpleVocabulary) self.assertEqual(list(vocabulary), []) def test_w_registration(self): diff --git a/src/zope/security/tests/test_protectclass.py b/src/zope/security/tests/test_protectclass.py index 4cbd95c..1a9f7c5 100644 --- a/src/zope/security/tests/test_protectclass.py +++ b/src/zope/security/tests/test_protectclass.py @@ -36,7 +36,7 @@ def test_wo_existing_checker_w_zope_Public(self): from zope.security.checker import CheckerPublic from zope.security.checker import _checkers self._callFUT(Foo, 'bar', zope_Public) - self.assertTrue(_checkers[Foo].get_permissions['bar'] is CheckerPublic) + self.assertIs(_checkers[Foo].get_permissions['bar'], CheckerPublic) def test_w_existing_checker(self): from zope.security.checker import Checker @@ -44,8 +44,8 @@ def test_w_existing_checker(self): checker = _checkers[Foo] = Checker({}) permission = object() self._callFUT(Foo, 'bar', permission) - self.assertTrue(_checkers[Foo] is checker) - self.assertTrue(checker.get_permissions['bar'] is permission) + self.assertIs(_checkers[Foo], checker) + self.assertIs(checker.get_permissions['bar'], permission) class Test_protectSetAttribute(unittest.TestCase): @@ -66,7 +66,7 @@ def test_wo_existing_checker_w_zope_Public(self): from zope.security.checker import CheckerPublic from zope.security.checker import _checkers self._callFUT(Foo, 'bar', zope_Public) - self.assertTrue(_checkers[Foo].set_permissions['bar'] is CheckerPublic) + self.assertIs(_checkers[Foo].set_permissions['bar'], CheckerPublic) def test_w_existing_checker(self): from zope.security.checker import Checker @@ -74,8 +74,8 @@ def test_w_existing_checker(self): checker = _checkers[Foo] = Checker({}) permission = object() self._callFUT(Foo, 'bar', permission) - self.assertTrue(_checkers[Foo] is checker) - self.assertTrue(checker.set_permissions['bar'] is permission) + self.assertIs(_checkers[Foo], checker) + self.assertIs(checker.set_permissions['bar'], permission) class Test_protectLikeUnto(unittest.TestCase): @@ -94,10 +94,10 @@ def _callFUT(self, class_, like_unto): def test_wo_existing_like_unto_checker(self): from zope.security.checker import _checkers - self.assertFalse(Foo in _checkers) + self.assertNotIn(Foo, _checkers) self._callFUT(Bar, Foo) - self.assertFalse(Foo in _checkers) - self.assertFalse(Bar in _checkers) + self.assertNotIn(Foo, _checkers) + self.assertNotIn(Bar, _checkers) def test_w_existing_like_unto_checker_wo_existing_checker(self): from zope.security.checker import Checker diff --git a/src/zope/security/tests/test_proxy.py b/src/zope/security/tests/test_proxy.py index dd5fcdc..3811787 100644 --- a/src/zope/security/tests/test_proxy.py +++ b/src/zope/security/tests/test_proxy.py @@ -271,25 +271,25 @@ def test__le__(self): target = 1 checker = object() # checker not consulted proxy = self._makeOne(target, checker) - self.assertTrue(proxy <= 1) + self.assertLessEqual(proxy, 1) def test__ne__(self): target = 1 checker = object() # checker not consulted proxy = self._makeOne(target, checker) - self.assertFalse(proxy != 1) + self.assertEqual(proxy, 1) def test__ge__(self): target = 1 checker = object() # checker not consulted proxy = self._makeOne(target, checker) - self.assertTrue(proxy >= 1) + self.assertGreaterEqual(proxy, 1) def test__gt__(self): target = 1 checker = object() # checker not consulted proxy = self._makeOne(target, checker) - self.assertTrue(proxy > 0) + self.assertGreater(proxy, 0) def test___hash___w_self(self): target = object() @@ -1081,14 +1081,14 @@ def test___contains___hit_w_checker_allows(self): target = [0, 1, 2] checker = DummyChecker() proxy = self._makeOne(target, checker) - self.assertTrue(1 in proxy) + self.assertIn(1, proxy) self.assertEqual(checker._checked, '__contains__') def test___contains___miss_w_checker_allows(self): target = [0, 1, 2] checker = DummyChecker() proxy = self._makeOne(target, checker) - self.assertFalse(4 in proxy) + self.assertNotIn(4, proxy) self.assertEqual(checker._checked, '__contains__') def test___contains___w_checker_forbids(self): @@ -1641,7 +1641,7 @@ def testCallFail(self): self.shouldFail(self.p, None) def testRichCompareOK(self): - self.assertTrue(self.p == self.x) + self.assertEqual(self.p, self.x) # def testRichCompareFail(self): # self.shouldFail(lambda: self.p == self.x) @@ -1689,7 +1689,7 @@ def doit(): self.shouldFail(doit) def testContainsOK(self): - self.assertTrue(42 in self.p) + self.assertIn(42, self.p) def testContainsFail(self): self.shouldFail(lambda: 42 in self.p) diff --git a/src/zope/security/tests/test_simpleinteraction.py b/src/zope/security/tests/test_simpleinteraction.py index 4fefddf..78ae990 100644 --- a/src/zope/security/tests/test_simpleinteraction.py +++ b/src/zope/security/tests/test_simpleinteraction.py @@ -38,8 +38,8 @@ def test_add(self): rq = RequestStub() interaction = ParanoidSecurityPolicy() interaction.add(rq) - self.assertTrue(rq in interaction.participations) - self.assertTrue(rq.interaction is interaction) + self.assertIn(rq, interaction.participations) + self.assertIs(rq.interaction, interaction) # rq already added self.assertRaises(ValueError, interaction.add, rq) @@ -57,8 +57,8 @@ def test_remove(self): interaction.add(rq) interaction.remove(rq) - self.assertTrue(rq not in interaction.participations) - self.assertTrue(rq.interaction is None) + self.assertNotIn(rq, interaction.participations) + self.assertIsNone(rq.interaction) def testCreateInteraction(self): from zope.interface.verify import verifyObject diff --git a/src/zope/security/tests/test_simplepolicies.py b/src/zope/security/tests/test_simplepolicies.py index 391f942..4d2a1d1 100644 --- a/src/zope/security/tests/test_simplepolicies.py +++ b/src/zope/security/tests/test_simplepolicies.py @@ -53,9 +53,9 @@ class Participation: p1, p2, p3 = Participation(), Participation(), Participation() policy = self._makeOne(p1, p2, p3) self.assertEqual(policy.participations, [p1, p2, p3]) - self.assertTrue(p1.interaction is policy) - self.assertTrue(p2.interaction is policy) - self.assertTrue(p3.interaction is policy) + self.assertIs(p1.interaction, policy) + self.assertIs(p2.interaction, policy) + self.assertIs(p3.interaction, policy) def test_add_w_foreign_participation(self): class Participation: @@ -77,9 +77,9 @@ class Participation: policy.remove(p2) self.assertEqual(policy.participations, [p1, p3]) - self.assertTrue(p1.interaction is policy) - self.assertTrue(p2.interaction is None) - self.assertTrue(p3.interaction is policy) + self.assertIs(p1.interaction, policy) + self.assertIsNone(p2.interaction) + self.assertIs(p3.interaction, policy) def test_checkPermission_w_public(self): from zope.security.checker import CheckerPublic diff --git a/src/zope/security/tests/test_zcml.py b/src/zope/security/tests/test_zcml.py index 366ee4c..7b24f27 100644 --- a/src/zope/security/tests/test_zcml.py +++ b/src/zope/security/tests/test_zcml.py @@ -53,7 +53,7 @@ def test_fromUnicode_hit(self): permission = self._makeOne() p_obj = object() permission.context.permission_mapping = {'extant.permission': p_obj} - self.assertTrue(permission.fromUnicode('extant.permission') is p_obj) + self.assertIs(permission.fromUnicode('extant.permission'), p_obj) def test__validate_w_public(self): context = DummyZCMLContext() @@ -116,8 +116,8 @@ def test_wo_description(self): self.assertEqual(permission.id, 'a.permission') self.assertEqual(permission.title, 'TITLE') self.assertEqual(permission.description, '') - self.assertTrue(context._actions[1]['discriminator'] is None) - self.assertTrue(context._actions[1]['callable'] is provideInterface) + self.assertIsNone(context._actions[1]['discriminator']) + self.assertIs(context._actions[1]['callable'], provideInterface) self.assertEqual(context._actions[1]['args'], ('', IPermission)) def test_w_description(self): @@ -138,8 +138,8 @@ def test_w_description(self): self.assertEqual(permission.id, 'a.permission') self.assertEqual(permission.title, 'TITLE') self.assertEqual(permission.description, 'DESCRIPTION') - self.assertTrue(context._actions[1]['discriminator'] is None) - self.assertTrue(context._actions[1]['callable'] is provideInterface) + self.assertIsNone(context._actions[1]['discriminator']) + self.assertIs(context._actions[1]['callable'], provideInterface) self.assertEqual(context._actions[1]['args'], ('', IPermission)) diff --git a/tox.ini b/tox.ini index 2e917ee..3a09c69 100644 --- a/tox.ini +++ b/tox.ini @@ -16,17 +16,13 @@ envlist = py38-watch, py311-watch [testenv] -pip_pre = py313: true deps = - setuptools < 69 - Sphinx + setuptools <74 setenv = pure: PURE_PYTHON=1 !pure-!pypy3: PURE_PYTHON=0 ZOPE_INTERFACE_STRICT_IRO=1 watch: ZOPE_WATCH_CHECKERS=1 - py312: VIRTUALENV_PIP=23.1.2 - py312: PIP_REQUIRE_VIRTUALENV=0 commands = zope-testrunner --test-path=src {posargs:-vc} sphinx-build -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest @@ -34,25 +30,31 @@ extras = test docs +[testenv:setuptools-latest] +basepython = python3 +deps = + git+https://github.com/pypa/setuptools.git\#egg=setuptools + [testenv:coverage] basepython = python3 allowlist_externals = mkdir deps = - coverage + coverage[toml] setenv = PURE_PYTHON=1 commands = mkdir -p {toxinidir}/parts/htmlcov coverage run -m zope.testrunner --test-path=src {posargs:-vc} - coverage html -i - coverage report -i -m --fail-under=99.5 + coverage html + coverage report [testenv:release-check] description = ensure that the distribution is ready to release basepython = python3 skip_install = true deps = + setuptools <74 twine build check-manifest