Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
gone committed Feb 23, 2022
2 parents a31e2fd + 2442ca2 commit 550be1b
Show file tree
Hide file tree
Showing 16 changed files with 79 additions and 47 deletions.
19 changes: 4 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,24 @@ on: [push, pull_request]

jobs:
build:
runs-on: ${{ matrix.os }}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 3.9, pypy3]
os: [ubuntu-18.04]
python-version: [3.5, 3.6, 3.7, 3.8, 3.9, "3.10", pypy3]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python }} (deadsnakes)
uses: deadsnakes/action@v1.0.0
if: endsWith(matrix.python-version, '-dev')
with:
python-version: ${{ matrix.python-version }}

- name: Set up Python ${{ matrix.python-version }}
if: "!endsWith(matrix.python-version, '-dev')"
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Ubuntu cache
uses: actions/cache@v1
if: startsWith(matrix.os, 'ubuntu')
- name: Cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key:
Expand All @@ -47,12 +38,10 @@ jobs:
python3 -m pip install ".[test]"
- name: Tests
shell: bash
run: |
python -m testtools.run testtools.tests.test_suite
- name: Docs
shell: bash
run: |
make clean-sphinx docs
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ clean-sphinx:

# Build the html docs using Sphinx.
html-sphinx:
cd doc && make html
cd doc && PYTHONPATH=.. make html

.PHONY: apidocs docs-sphinx clean-sphinx html-sphinx docs
.PHONY: check clean prerelease release
32 changes: 26 additions & 6 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,30 @@ NEXT
Improvements
------------

* Add support for Python 3.10.
(Jürgen Gmach)

* Distutils integration is deprecated and will be removed in the next major
version.

2.5.0
~~~~~

Improvements
------------

* Add support for Python 3.9.
(Hugo van Kemenade)

* Python 3.5 has reached end-of-life and this is the last release to support it.

* The skip, skipIf, and skipUnless decorators can now be used as class
decorators as well as test method decorators, just as they can in
unittest.

* The ``SameMembers`` matcher class is now exposed as part of the public
matchers API.

Changes
-------

Expand All @@ -22,7 +42,7 @@ Changes

* The ``safe_hasattr`` utility has been removed from ``testtools.helpers``.
This was a compat wrapper introduced in 0.9.25 when the utility itself was
moved to the ``extras`` package. It is no longer useless on Python 3-only
moved to the ``extras`` package. It is no longer used on Python 3-only
projects.

* The ``try_imports`` utility has been removed from ``testtools.helpers``.
Expand Down Expand Up @@ -72,7 +92,7 @@ Improvements

* Don't add file details without content. (Thomas Herve, Github #252)

* Make ``testtools.twistedsupport and tests work on Python 3. (Free Ekanayaka)
* Make ``testtools.twistedsupport`` and tests work on Python 3. (Free Ekanayaka)

2.2.0
~~~~~
Expand Down Expand Up @@ -577,7 +597,7 @@ experimental and we might need to break it if it turns out to be unsuitable.

Improvements
------------
* ``assertRaises`` works properly for exception classes that have custom
* ``assertRaises`` works properly for exception classes that have custom
metaclasses

* ``ConcurrentTestSuite`` was silently eating exceptions that propagate from
Expand Down Expand Up @@ -764,14 +784,14 @@ Improvements
Changes
-------

* ``testtools.run discover`` will now sort the tests it discovered. This is a
* ``testtools.run discover`` will now sort the tests it discovered. This is a
workaround for http://bugs.python.org/issue16709. Non-standard test suites
are preserved, and their ``sort_tests()`` method called (if they have such an
attribute). ``testtools.testsuite.sorted_tests(suite, True)`` can be used by
such suites to do a local sort. (Robert Collins, #1091512)

* ``ThreadsafeForwardingResult`` now defines a stub ``progress`` method, which
fixes ``testr run`` of streams containing progress markers (by discarding the
fixes ``testr run`` of streams containing progress markers (by discarding the
progress data). (Robert Collins, #1019165)

0.9.23
Expand Down Expand Up @@ -1591,7 +1611,7 @@ Improvements
systems where os.sep is not '/'.

* When a cleanUp or tearDown exception occurs, it is now accumulated as a new
traceback in the test details, rather than as a separate call to addError /
traceback in the test details, rather than as a separate call to addError /
addException. This makes testtools work better with most TestResult objects
and fixes bug #335816.

Expand Down
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ If you would like to learn more about testtools, consult our documentation in
the 'doc/' directory. You might like to start at 'doc/overview.rst' or
'doc/for-test-authors.rst'.

To build HTML versions of the documentation, make sure you have
sphinx installed and run ``make docs``.


Licensing
---------
Expand Down
8 changes: 8 additions & 0 deletions doc/for-test-authors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ From now on, we'll assume that you know how to run your tests.
Running test with Distutils
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. deprecated:: 2.6.0

Distutils integration was deprecated in 2.6.0. You should consider
replacing invocations of ``python setup.py test`` with a suitable
alternative such as ``tox``. Refer to `this issue`__ for more information.

.. __: https://github.com/pypa/setuptools/issues/1684

If you are using Distutils_ to build your Python project, you can use the testtools
Distutils_ command to integrate testtools into your Distutils_ workflow::

Expand Down
8 changes: 0 additions & 8 deletions doc/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ What better way to start than with a contrived code snippet?::
Why use testtools?
==================

Better assertion methods
------------------------

The standard assertion methods that come with unittest aren't as helpful as
they could be, and there aren't quite enough of them. testtools adds
``assertIn``, ``assertIs``, ``assertIsInstance`` and their negatives.


Matchers: better than assertion methods
---------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion scripts/all-pythons
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@ def now():
if __name__ == '__main__':
sys.path.append(ROOT)
result = TestProtocolClient(sys.stdout)
for version in '3.5 3.6 3.7 3.8'.split():
for version in '3.5 3.6 3.7 3.8 3.9 3.10'.split():
run_for_python(version, result, sys.argv[1:])
8 changes: 5 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[metadata]
name = testtools
summary = Extensions to the Python standard library unit testing framework
home-page = https://github.com/testing-cabal/testtools
description-file = doc/overview.rst
home_page = https://github.com/testing-cabal/testtools
description_file = doc/overview.rst
author = Jonathan M. Lange
author-email = jml+testtools@mumak.net
author_email = jml+testtools@mumak.net
classifier =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
Expand All @@ -16,6 +16,8 @@ classifier =
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
Expand Down
5 changes: 4 additions & 1 deletion testtools/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
'advance_iterator',
'reraise',
'unicode_output_stream',
'StringIO',
'BytesIO',
]

import codecs
Expand All @@ -16,6 +18,8 @@
import os
import sys
import unicodedata
# Ensure retro-compatibility with older testtools releases
from io import StringIO, BytesIO


def reraise(exc_class, exc_obj, exc_tb, _marker=object()):
Expand Down Expand Up @@ -150,4 +154,3 @@ def _get_exception_encoding():
# setting that can change after the message is formatted.
return locale.getlocale(locale.LC_MESSAGES)[1] or "ascii"


12 changes: 10 additions & 2 deletions testtools/distutilscmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""Extensions to the standard Python unittest library."""

import sys
import warnings

from distutils.core import Command
from distutils.errors import DistutilsOptionError
Expand All @@ -19,15 +20,22 @@ class TestCommand(Command):
('catch', 'c', "Catch ctrl-C and display results so far"),
('buffer', 'b', "Buffer stdout and stderr during tests"),
('failfast', 'f', "Stop on first fail or error"),
('test-module=','m', "Run 'test_suite' in specified module"),
('test-suite=','s',
('test-module=', 'm', "Run 'test_suite' in specified module"),
('test-suite=', 's',
"Test suite to run (e.g. 'some_module.test_suite')")
]

def __init__(self, dist):
Command.__init__(self, dist)
self.runner = TestToolsTestRunner(stdout=sys.stdout)

warnings.warn(
"Distutils integration is deprecated and will be removed in the "
"next major release. "
"Refer to https://github.com/pypa/setuptools/issues/1684 for more "
"information.",
DeprecationWarning,
)

def initialize_options(self):
self.test_suite = None
Expand Down
2 changes: 2 additions & 0 deletions testtools/matchers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
'PathExists',
'Raises',
'raises',
'SameMembers',
'SamePath',
'StartsWith',
'TarballContains',
Expand All @@ -71,6 +72,7 @@
LessThan,
MatchesRegex,
NotEquals,
SameMembers,
StartsWith,
)
from ._const import (
Expand Down
1 change: 1 addition & 0 deletions testtools/matchers/_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'LessThan',
'MatchesRegex',
'NotEquals',
'SameMembers',
'StartsWith',
]

Expand Down
13 changes: 6 additions & 7 deletions testtools/matchers/_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
def WarningMessage(category_type, message=None, filename=None, lineno=None,
line=None):
r"""
Create a matcher that will match `warnings.WarningMessage`s.
Create a matcher that will match `warnings.WarningMessage`\s.
For example, to match captured `DeprecationWarning`s with a message about
some ``foo`` being replaced with ``bar``:
Expand All @@ -34,16 +34,15 @@ def WarningMessage(category_type, message=None, filename=None, lineno=None,
Contains('foo is deprecated'),
Contains('use bar instead')))
:param type category_type: A warning type, for example
`DeprecationWarning`.
:param type category_type: A warning type, for example `DeprecationWarning`.
:param message_matcher: A matcher object that will be evaluated against
warning's message.
warning's message.
:param filename_matcher: A matcher object that will be evaluated against
the warning's filename.
the warning's filename.
:param lineno_matcher: A matcher object that will be evaluated against the
warning's line number.
warning's line number.
:param line_matcher: A matcher object that will be evaluated against the
warning's line of source code.
warning's line of source code.
"""
category_matcher = Is(category_type)
message_matcher = message or Always()
Expand Down
7 changes: 6 additions & 1 deletion testtools/tests/test_testresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -2667,14 +2667,19 @@ def test_syntax_error(self):
"""Syntax errors should still have fancy special-case formatting"""
if platform.python_implementation() == "PyPy":
spaces = ' '
marker = '^'
elif sys.version_info >= (3, 10):
spaces = ' '
marker = '^^^'
else:
spaces = ' '
marker = '^'
textoutput = self._test_external_case("exec ('f(a, b c)')")
self.assertIn(self._as_output(
' File "<string>", line 1\n'
' f(a, b c)\n'
+ ' ' * self._error_on_character +
spaces + '^\n'
spaces + marker + '\n'
'SyntaxError: '
), textoutput)

Expand Down
2 changes: 1 addition & 1 deletion testtools/tests/test_testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def run(self):
test.run(process_result)
""", doctest.ELLIPSIS))
self.assertThat(events[3][6].decode('utf8'), DocTestMatches("""\
TypeError: run() takes ...1 ...argument...2...given...
TypeError: ...run() takes ...1 ...argument...2...given...
""", doctest.ELLIPSIS))
events = [event[0:10] + (None,) for event in events]
events[1] = events[1][:6] + (None,) + events[1][7:]
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py35,py36,py37,py38,py39,pypy3
envlist = py35,py36,py37,py38,py39,py310,pypy3
minversion = 1.6

[testenv]
Expand Down

0 comments on commit 550be1b

Please sign in to comment.