Skip to content

Commit

Permalink
Add 3.9, drop 3.5, adapt to changes in zope.interface 5.4, move to GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Sep 8, 2021
1 parent feecfc9 commit cd667f8
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 26 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/tests.yml
@@ -0,0 +1,52 @@
name: tests

on: [push, pull_request]

env:
PYTHONHASHSEED: 1042466059
ZOPE_INTERFACE_STRICT_IRO: 1


jobs:
test:
strategy:
matrix:
python-version: [2.7, pypy2, pypy3, 3.6, 3.7, 3.8, 3.9]

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('setup.*') }}-${{ matrix.python-version }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install -U pip setuptools wheel
python -m pip install -U coverage
python -m pip install -U -e ".[test,docs]"
- name: Test
run: |
coverage run -m zope.testrunner --test-path=src --auto-color --auto-progress
coverage run -a -m sphinx -b doctest -d docs/_build/doctrees docs docs/_build/doctests
- name: Submit to Coveralls
# This is a container action, which only runs on Linux.
uses: AndreMiras/coveralls-python-action@develop
with:
parallel: true

coveralls_finish:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: AndreMiras/coveralls-python-action@develop
with:
parallel-finished: true
11 changes: 9 additions & 2 deletions CHANGES.rst
Expand Up @@ -3,11 +3,12 @@
=========


3.0.1 (unreleased)
3.1.0 (unreleased)
==================

- Nothing changed yet.
- Add support for Python 3.9.

- Drop support for Python 3.5.

3.0.0 (2020-06-16)
==================
Expand Down Expand Up @@ -45,12 +46,15 @@

- Make ``Acquisition`` an optional dependency. If it is not installed,
the ``aq_inContextOf`` matcher will always return False.

- Remove dependency on ``fudge``. Instead, we now use ``unittest.mock`` on
Python 3, or its backport ``mock`` on Python 2. See `issue 11
<https://github.com/NextThought/nti.testing/issues/11>`_.

- Refactor ZCML configuration support to share more code and
documentation. See `issue 10
<https://github.com/NextThought/nti.testing/issues/10>`_.

- The layer ``ConfiguringLayerMixin`` and the base class
``SharedConfiguringTestBase`` now default to running
configuration in the package the subclass is defined in, just as
Expand All @@ -75,12 +79,15 @@
==================

- Add support for Python 3.6.

- Remove ``unicode_literals``.

- Substantially rework ``time_monotonically_increases`` for greater
safety. Fixes `issue 5 <https://github.com/NextThought/nti.testing/issues/5>`_.

1.0.0 (2016-07-28)
==================

- Add Python 3 support.

- Initial PyPI release.
19 changes: 10 additions & 9 deletions README.rst
Expand Up @@ -10,8 +10,9 @@
:target: https://pypi.org/project/nti.testing/
:alt: Supported Python versions

.. image:: https://travis-ci.org/NextThought/nti.testing.svg?branch=master
:target: https://travis-ci.org/NextThought/nti.testing
.. image:: https://github.com/NextThought/nti.testing/actions/workflows/tests.yml/badge.svg
:target: https://github.com/NextThought/nti.testing/actions/workflows/tests.yml
:alt: Test Status

.. image:: https://coveralls.io/repos/github/NextThought/nti.testing/badge.svg
:target: https://coveralls.io/github/NextThought/nti.testing
Expand Down Expand Up @@ -97,8 +98,8 @@ specified by the interface are present as described::
Traceback (most recent call last):
...
AssertionError:...
Expected: object verifiably providing <InterfaceClass ...IThings>
but: Using class <class 'Thing'> the object <object Thing> has failed to implement interface <InterfaceClass ....IThings>: The ....IThings.got_that_thing_i_sent_you attribute was not provided.
Expected: object verifiably providing <...IThings>
but: Using class <class 'Thing'> the object <object Thing> has failed to implement interface ....IThings: The ....IThings.got_that_thing_i_sent_you attribute was not provided.
<BLANKLINE>

If multiple attributes or methods are not provided, all such missing
Expand All @@ -114,8 +115,8 @@ information is reported::
Traceback (most recent call last):
...
AssertionError:...
Expected: object verifiably providing <InterfaceClass ...IThingReceiver>
but: Using class <class 'ThingReceiver'> the object <object ThingReceiver> has failed to implement interface <InterfaceClass ....IThingReceiver>:
Expected: object verifiably providing <...IThingReceiver>
but: Using class <class 'ThingReceiver'> the object <object ThingReceiver> has failed to implement interface ....IThingReceiver:
The ....IThings.got_that_thing_i_sent_you attribute was not provided
The ....IThingReceiver.receive(some_thing) attribute was not provided
<BLANKLINE>
Expand All @@ -127,7 +128,7 @@ values of the attributes, we can step up to ``zope.schema`` and the

>>> from zope.schema import Bool
>>> class IBoolThings(IThing1, IThing2):
... got_that_thing_i_sent_you = Bool()
... got_that_thing_i_sent_you = Bool(required=True)
>>> @implementer(IBoolThings)
... class BoolThing(object):
... def __repr__(self): return "<object BoolThing>"
Expand All @@ -140,8 +141,8 @@ values of the attributes, we can step up to ``zope.schema`` and the
Traceback (most recent call last):
...
AssertionError:...
Expected: (object verifiably providing <InterfaceClass ...IBoolThings> and object validly providing <InterfaceClass ....IBoolThings>)
but: object verifiably providing <InterfaceClass ....IBoolThings> Using class <class 'BoolThing'> the object <object BoolThing> has failed to implement interface <InterfaceClass ....IBoolThings>: The ....IBoolThings.got_that_thing_i_sent_you attribute was not provided.
Expected: (object verifiably providing <...IBoolThings> and object validly providing ....IBoolThings)
but: object verifiably providing <....IBoolThings> Using class <class 'BoolThing'> the object <object BoolThing> has failed to implement interface ....IBoolThings: The ....IBoolThings.got_that_thing_i_sent_you attribute was not provided.
<BLANKLINE>

For finer grained control, we can compare data against schema fields::
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Expand Up @@ -38,6 +38,7 @@
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.viewcode',
'sphinx.ext.doctest',
]

# Add any paths that contain templates here, relative to this directory.
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Expand Up @@ -39,10 +39,10 @@ def _read(fname):
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Software Development :: Testing',
Expand All @@ -54,7 +54,8 @@ def _read(fname):
namespace_packages=['nti'],
install_requires=[
'ZODB >= 5.6.0',
'zope.interface >= 5.1', # Error messages changed.
# Error messages changed in 5.1, reprs changed <= 5.4
'zope.interface >= 5.4.0',
'pyhamcrest',
'six',
'setuptools',
Expand Down
11 changes: 5 additions & 6 deletions src/nti/testing/matchers.py
Expand Up @@ -11,9 +11,9 @@
# stdlib imports
try:
from collections.abc import Sequence, Mapping
except ImportError:
except ImportError: # pragma: no cover
# Python 2
from collections import Sequence, Mapping
from collections import Sequence, Mapping # pylint:disable=deprecated-class
import pprint

import six
Expand Down Expand Up @@ -49,7 +49,6 @@
'TypeCheckedDict',
]

has_length = has_length # Export
is_empty = empty # bwc

has_attr = hamcrest.library.has_property
Expand Down Expand Up @@ -314,10 +313,10 @@ def aq_inContextOf(parent):

# Patch hamcrest for better descriptions of maps (json data)
# and sequences
if six.PY3: # pragma: no cover
if six.PY3:
from io import StringIO
else:
from cStringIO import StringIO
else: # pragma: no cover
from cStringIO import StringIO # pylint:disable=import-error

_orig_append_description_of = BaseDescription.append_description_of
def _append_description_of_map(self, value):
Expand Down
3 changes: 2 additions & 1 deletion src/nti/testing/time.py
Expand Up @@ -17,7 +17,8 @@

try:
from unittest import mock
except ImportError:
except ImportError: # pragma: no cover
# Python 2
import mock

import six
Expand Down
14 changes: 8 additions & 6 deletions tox.ini
@@ -1,26 +1,28 @@
[tox]
envlist = pypy,py27,py35,py36,py37,py38,pypy3,coverage,docs
envlist = pypy,py27,py36,py37,py38,py39,pypy3,coverage,docs

[testenv]
deps =
.[test]
extras =
test
commands =
zope-testrunner --test-path=src --auto-color --auto-progress [] # substitute with tox positional args
setenv =
PYTHONHASHSEED=1042466059
ZOPE_INTERFACE_STRICT_IRO=1

[testenv:coverage]
basepython = python3
usedevelop = true
commands =
coverage run -m zope.testrunner --test-path=src []
coverage html
coverage report --fail-under=100
deps =
{[testenv]deps}
coverage

[testenv:docs]
commands =
sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html
deps =
.[docs]
sphinx-build -b doctest -d docs/_build/doctrees docs docs/_build/doctests
extras =
docs

0 comments on commit cd667f8

Please sign in to comment.