Skip to content

Commit

Permalink
Drop support for Python < 3.7 (#146)
Browse files Browse the repository at this point in the history
* Bumped version for breaking release.

* Drop support for Python 2.7, 3.5, 3.6.

* Configuring for pure-python

* Drop support for Python 2.7 up to 3.6.

* Improve resource warnings.

Fixes #144.
  • Loading branch information
Michael Howitz committed Mar 28, 2023
1 parent 5e0087f commit 73bfbcb
Show file tree
Hide file tree
Showing 47 changed files with 285 additions and 495 deletions.
16 changes: 3 additions & 13 deletions .github/workflows/tests.yml
Expand Up @@ -22,33 +22,23 @@ jobs:
config:
# [Python version, tox env]
- ["3.9", "lint"]
- ["2.7", "py27"]
- ["3.5", "py35"]
- ["3.6", "py36"]
- ["3.7", "py37"]
- ["3.8", "py38"]
- ["3.9", "py39"]
- ["3.10", "py310"]
- ["3.11", "py311"]
- ["pypy-2.7", "pypy"]
- ["pypy-3.7", "pypy3"]
- ["pypy-3.9", "pypy3"]
- ["3.9", "docs"]
- ["3.9", "coverage"]
- ["2.7", "py27-subunit"]
- ["3.5", "py35-subunit"]
- ["3.6", "py36-subunit"]
- ["3.7", "py37-subunit"]
- ["3.8", "py38-subunit"]
- ["3.9", "py39-subunit"]
- ["3.10", "py310-subunit"]
- ["3.11", "py311-subunit"]
- ["pypy-2.7", "pypy-subunit"]
- ["pypy-3.7", "pypy3-subunit"]
- ["pypy-3.9", "pypy3-subunit"]
exclude:
- { os: ["windows", "windows-latest"], config: ["3.9", "lint"] }
- { os: ["windows", "windows-latest"], config: ["3.9", "docs"] }
- { os: ["windows", "windows-latest"], config: ["3.9", "coverage"] }
- { os: ["windows", "windows-latest"], config: ["pypy-2.7", "pypy-subunit"] }

runs-on: ${{ matrix.os[1] }}
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
Expand Down Expand Up @@ -76,7 +66,7 @@ jobs:
- name: Coverage
if: matrix.config[1] == 'coverage'
run: |
pip install coveralls coverage-python-version
pip install coveralls
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 3 additions & 11 deletions .meta.toml
Expand Up @@ -2,11 +2,10 @@
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
[meta]
template = "pure-python"
commit-id = "180c99ed3def7da6e173a5a496cad6484eadd044"
commit-id = "1514f236"

[python]
with-pypy = true
with-legacy-python = true
with-docs = true
with-sphinx-doctests = false
with-windows = true
Expand Down Expand Up @@ -42,7 +41,7 @@ additional-config = [

[tox]
additional-envlist = [
"py{27,35,36,37,38,39,310,311,py,py3}-subunit",
"py{37,38,39,310,311,py3}-subunit",
]
testenv-deps = [
]
Expand All @@ -54,17 +53,10 @@ use-flake8 = true

[github-actions]
additional-config = [
"- [\"2.7\", \"py27-subunit\"]",
"- [\"3.5\", \"py35-subunit\"]",
"- [\"3.6\", \"py36-subunit\"]",
"- [\"3.7\", \"py37-subunit\"]",
"- [\"3.8\", \"py38-subunit\"]",
"- [\"3.9\", \"py39-subunit\"]",
"- [\"3.10\", \"py310-subunit\"]",
"- [\"3.11\", \"py311-subunit\"]",
"- [\"pypy-2.7\", \"pypy-subunit\"]",
"- [\"pypy-3.7\", \"pypy3-subunit\"]",
]
additional-exclude = [
"- { os: [\"windows\", \"windows-latest\"], config: [\"pypy-2.7\", \"pypy-subunit\"] }",
"- [\"pypy-3.9\", \"pypy3-subunit\"]",
]
4 changes: 2 additions & 2 deletions CHANGES.rst
Expand Up @@ -2,10 +2,10 @@
zope.testrunner Changelog
===========================

5.7 (unreleased)
6.0 (unreleased)
================

- Nothing changed yet.
- Drop support for Python 2.7, 3.5, 3.6.


5.6 (2022-12-09)
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
@@ -1,7 +1,7 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
[bdist_wheel]
universal = 1
universal = 0

[flake8]
doctests = 1
Expand Down Expand Up @@ -29,7 +29,7 @@ ignore =
force_single_line = True
combine_as_imports = True
sections = FUTURE,STDLIB,THIRDPARTY,ZOPE,FIRSTPARTY,LOCALFOLDER
known_third_party = six, docutils, pkg_resources
known_third_party = six, docutils, pkg_resources, pytz
known_zope =
known_first_party =
default_section = ZOPE
Expand Down
11 changes: 3 additions & 8 deletions setup.py
Expand Up @@ -23,11 +23,10 @@
from setuptools.command.test import test


version = '5.7.dev0'
version = '6.0.dev0'

INSTALL_REQUIRES = [
'setuptools',
'six',
'zope.exceptions',
'zope.interface',
]
Expand Down Expand Up @@ -133,7 +132,7 @@ def read(*names):
description='Zope testrunner script.',
long_description=long_description,
author='Zope Foundation and Contributors',
author_email='zope-dev@zope.org',
author_email='zope-dev@zope.dev',
packages=[
"zope",
"zope.testrunner",
Expand All @@ -147,11 +146,7 @@ def read(*names):
"License :: OSI Approved :: Zope Public License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"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",
Expand All @@ -163,7 +158,7 @@ def read(*names):
"Topic :: Software Development :: Testing",
],
namespace_packages=['zope'],
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*',
python_requires='>=3.7',
install_requires=INSTALL_REQUIRES,
tests_require=TESTS_REQUIRE,
extras_require=EXTRAS_REQUIRE,
Expand Down
4 changes: 2 additions & 2 deletions src/zope/testrunner/coverage.py
Expand Up @@ -83,7 +83,7 @@ def stop(self):
self.started = False


class TestIgnore(object):
class TestIgnore:

def __init__(self, directories):
self._test_dirs = [self._filenameFormat(d[0]) + os.path.sep
Expand Down Expand Up @@ -130,7 +130,7 @@ class Coverage(zope.testrunner.feature.Feature):
directory = None

def __init__(self, runner):
super(Coverage, self).__init__(runner)
super().__init__(runner)
self.active = bool(runner.options.coverage)

def global_setup(self):
Expand Down
3 changes: 1 addition & 2 deletions src/zope/testrunner/debug.py
Expand Up @@ -14,7 +14,6 @@
"""Debug functions
"""
from __future__ import print_function

import doctest
import io
Expand Down Expand Up @@ -85,4 +84,4 @@ def print_doctest_location(err):
filename = err.test.filename
if filename.endswith('.pyc'):
filename = filename[:-1]
print("> %s(%s)_()" % (filename, err.test.lineno+err.example.lineno+1))
print("> {}({})_()".format(filename, err.test.lineno+err.example.lineno+1))
4 changes: 2 additions & 2 deletions src/zope/testrunner/digraph.py
Expand Up @@ -17,7 +17,7 @@
from itertools import count


class DiGraph(object):
class DiGraph:
"""Directed graph.
A directed graph is a set of nodes together with a
Expand Down Expand Up @@ -186,7 +186,7 @@ def sccs(self, trivial=False):
visits.extend(self._neighbors.get(node, ()))


class _TarjanState(object):
class _TarjanState:
"""representation of a node's processing state."""
__slots__ = "stacked dfs low".split()

Expand Down
1 change: 0 additions & 1 deletion src/zope/testrunner/eggsupport.py
@@ -1,6 +1,5 @@
""" Add unit and functional testing support to setuptools-driven eggs.
"""
from __future__ import print_function

from setuptools.command.test import ScanningLoader
from setuptools.command.test import test as BaseCommand
Expand Down
2 changes: 1 addition & 1 deletion src/zope/testrunner/feature.py
Expand Up @@ -20,7 +20,7 @@


@zope.interface.implementer(zope.testrunner.interfaces.IFeature)
class Feature(object):
class Feature:
"""A base class implementing no-op methods for the IFeature interface."""

active = False
Expand Down
58 changes: 18 additions & 40 deletions src/zope/testrunner/find.py
Expand Up @@ -19,8 +19,6 @@
import sys
import unittest

import six

import zope.testrunner.debug
import zope.testrunner.feature
import zope.testrunner.layer
Expand Down Expand Up @@ -102,14 +100,13 @@ class StartUpFailure(unittest.TestCase):
>>> from zope.testrunner.interfaces import EndRun
>>> try: #doctest: +ELLIPSIS
... try: # try...except...finally doesn't work in Python 2.4
... # Needed to prevent the result from starting with '...'
... print("Result:")
... StartUpFailure(options, None, exc_info)
... except EndRun:
... except EndRun:
... print("EndRun raised")
... finally:
... sys.stdin = old_stdin
... sys.stdin = old_stdin
Result:
Exception: something bad happened during import
...
Expand Down Expand Up @@ -141,7 +138,7 @@ def __init__(self, options, module, exc_info):
zope.testrunner.debug.post_mortem(exc_info)
self.module = module
self.exc_info = exc_info
super(StartUpFailure, self).__init__()
super().__init__()

def shortDescription(self):
return 'StartUpFailure: import errors in %s.' % self.module
Expand All @@ -153,7 +150,12 @@ def runTest(self):
if self.exc_info is None or any(x is None for x in self.exc_info):
self.fail("could not import %s" % self.module)
else:
six.reraise(*self.exc_info)
try:
_, value, tb = self.exc_info
raise value.with_traceback(tb)
finally:
value = None
tb = None


def find_tests(options, found_suites=None):
Expand Down Expand Up @@ -232,9 +234,7 @@ def find_suites(options, accept=None):
"Module %s does not define any tests"
% module_name)

if isinstance(suite, unittest.TestSuite):
check_suite(suite, module_name)
else:
if not isinstance(suite, unittest.TestSuite):
# We extract the error message expression into a
# local variable because we want the `raise`
# statement to fit on a single line, to make the
Expand Down Expand Up @@ -356,8 +356,7 @@ def test_dirs(options, seen):
yield p, package
break
else:
for dpath in options.test_path:
yield dpath
yield from options.test_path


def walk_with_symlinks(options, dir):
Expand All @@ -371,8 +370,7 @@ def walk_with_symlinks(options, dir):
for d in dirs:
p = os.path.join(dirpath, d)
if os.path.islink(p):
for sdirpath, sdirs, sfiles in walk_with_symlinks(options, p):
yield (sdirpath, sdirs, sfiles)
yield from walk_with_symlinks(options, p)


compiled_suffixes = '.pyc', '.pyo'
Expand Down Expand Up @@ -451,16 +449,16 @@ def tests_from_suite(suite, options, dlevel=1,

level = getattr(suite, 'level', dlevel)
layer = getattr(suite, 'layer', dlayer)
if not isinstance(layer, six.string_types):
if not isinstance(layer, str):
layer = name_from_layer(layer)

if isinstance(suite, unittest.TestSuite):
for possible_suite in suite:
for r in tests_from_suite(possible_suite, options, level, layer,
accept=accept,
seen_test_ids=seen_test_ids,
duplicated_test_ids=duplicated_test_ids):
yield r
yield from tests_from_suite(
possible_suite, options, level, layer,
accept=accept,
seen_test_ids=seen_test_ids,
duplicated_test_ids=duplicated_test_ids)
elif isinstance(suite, StartUpFailure):
yield (suite, None)
else:
Expand All @@ -475,26 +473,6 @@ def tests_from_suite(suite, options, dlevel=1,
yield (suite, layer)


def check_suite(suite, module_name):

"""Check for bad tests in a test suite.
"Bad tests" are those that do not inherit from unittest.TestCase.
Note that this function is pointless on Python 2.5, because unittest itself
checks for this in TestSuite.addTest. It is, however, useful on earlier
Pythons.
"""
for x in suite:
if isinstance(x, unittest.TestSuite):
check_suite(x, module_name)
elif not isinstance(x, unittest.TestCase):
raise TypeError(
"Invalid test, %r,\nin test_suite from %s"
% (x, module_name)
)


_layer_name_cache = {}


Expand Down

0 comments on commit 73bfbcb

Please sign in to comment.