Skip to content

Commit 6351909

Browse files
authored
Updates for python 3.11+
- update files based on setuptools recommendations - use pyproject.toml convention - use setuptools-scm to autogen version instead of xmlrunner/version.py - use `python -m build` instead of references to setup.py - use `license` and `license-files` directives - update python versions supported based on EOL - update tox config and `passenv` - fix `ValueError`, `flush()` on closed file in `_DuplicateWriter` - Fix test result description fetching on Python 3.11, see original contribution in #274 - try to fix refcounting issue in tests, see #285 - fix regression test for test discovery - fix discovery issue; python 3.12 introduced `_NO_TESTS_EXITCODE`, since then tox testcase failed. - skip coveralls
1 parent 3a2be20 commit 6351909

File tree

14 files changed

+163
-105
lines changed

14 files changed

+163
-105
lines changed

.coveragerc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[report]
22
include =
3-
setup.py
43
tests/*
54
xmlrunner/*

.github/workflows/tests.yml

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,29 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14+
name: [
15+
"py310",
16+
"py311",
17+
"py312",
18+
"py313",
19+
"py314",
20+
]
1421
include:
15-
- python-version: 3.7
16-
toxenv: py37
17-
- python-version: 3.8
18-
toxenv: py38
19-
- python-version: 3.8
20-
toxenv: py38-djangolts
21-
- python-version: 3.8
22-
toxenv: py38-djangocurr
23-
- python-version: 3.8
24-
toxenv: py38-quality
25-
- python-version: 3.9
26-
toxenv: py39
27-
- python-version: "3.10"
28-
toxenv: py310
22+
- name: py310
23+
python-version: "3.10"
24+
tox_env: py310
25+
- name: py311
26+
python-version: "3.11"
27+
tox_env: py311
28+
- name: py312
29+
python-version: "3.12"
30+
tox_env: py312
31+
- name: py313
32+
python-version: "3.13"
33+
tox_env: py313
34+
- name: py314
35+
python-version: "3.14"
36+
tox_env: py314
2937
steps:
3038
- name: Checkout
3139
uses: actions/checkout@v2
@@ -40,19 +48,21 @@ jobs:
4048
lsb_release -a
4149
- name: Install
4250
env:
43-
TOXENV: ${{ matrix.toxenv }}
51+
TOXENV: ${{ matrix.tox_env }}
4452
run: |
4553
pip install tox-gh-actions codecov coveralls
4654
pip --version
4755
tox --version
4856
- name: Script
4957
run: |
50-
tox -v
51-
env:
52-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
53-
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
58+
tox run -v
5459
- name: After Failure
5560
if: ${{ failure() }}
5661
run: |
5762
more .tox/log/* | cat
5863
more .tox/*/log/* | cat
64+
- name: Upload to Codecov
65+
run: |
66+
tox -e uploadcodecov
67+
env:
68+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ dist/*
1212
.tox
1313
.coverage
1414
htmlcov/
15+
16+
# autogenerated
17+
xmlrunner/version.py

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ checkversion:
1212
git show-ref --tags | grep -q $$(git log -1 --pretty=%H) || (echo "DID NOT TAG VERSION"; exit 1)
1313

1414
dist: checkversion build/publish/bin
15-
build/publish/bin/python setup.py sdist
16-
build/publish/bin/python setup.py bdist_wheel
15+
build/publish/bin/python -m build
1716

1817
publish: dist/ build/publish/bin
1918
build/publish/bin/twine upload dist/*

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ If you use Git and want to get the latest *development* version:
106106
````bash
107107
$ git clone https://github.com/xmlrunner/unittest-xml-reporting.git
108108
$ cd unittest-xml-reporting
109-
$ sudo python setup.py install
109+
$ sudo python -m pip install .
110110
````
111111

112112
Or get the latest *development* version as a tarball:
@@ -115,7 +115,7 @@ Or get the latest *development* version as a tarball:
115115
$ wget https://github.com/xmlrunner/unittest-xml-reporting/archive/master.zip
116116
$ unzip master.zip
117117
$ cd unittest-xml-reporting
118-
$ sudo python setup.py install
118+
$ sudo python -m pip install .
119119
````
120120

121121
Or you can manually download the latest released version from

pyproject.toml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
[build-system]
2+
build-backend = "setuptools.build_meta"
3+
requires = [
4+
"setuptools>=77",
5+
"setuptools-scm[toml]>=6.2.3",
6+
]
7+
8+
9+
[project]
10+
name = "unittest-xml-reporting"
11+
license = "BSD-2-Clause"
12+
license-files = [ "LICENSE" ]
13+
dynamic = [
14+
"version",
15+
]
16+
description = "unittest-based test runner with Ant/JUnit like XML reporting."
17+
keywords = [
18+
"pyunit",
19+
"unittest",
20+
"junit xml",
21+
"xunit",
22+
"report",
23+
"testrunner",
24+
"xmlrunner",
25+
]
26+
readme = "README.md"
27+
authors = [
28+
{name = "Daniel Fernandes Martins"},
29+
{name = "Damien Nozay"},
30+
]
31+
classifiers = [
32+
"Development Status :: 5 - Production/Stable",
33+
"Intended Audience :: Developers",
34+
"Natural Language :: English",
35+
"Operating System :: OS Independent",
36+
"Programming Language :: Python :: 3 :: Only",
37+
"Programming Language :: Python :: 3.10",
38+
"Programming Language :: Python :: 3.11",
39+
"Programming Language :: Python :: 3.12",
40+
"Programming Language :: Python :: 3.13",
41+
"Programming Language :: Python :: 3.14",
42+
"Programming Language :: Python :: Implementation :: CPython",
43+
"Programming Language :: Python :: Implementation :: PyPy",
44+
"Topic :: Software Development :: Libraries :: Python Modules",
45+
"Topic :: Software Development :: Testing",
46+
]
47+
requires-python = ">=3.10"
48+
dependencies = [
49+
"lxml",
50+
]
51+
52+
[project.urls]
53+
Homepage = "http://github.com/xmlrunner/unittest-xml-reporting/tree/master/"
54+
55+
56+
[tool.setuptools_scm]
57+
write_to = "xmlrunner/version.py"
58+
59+
[tool.distutils.bdist_wheel]
60+
universal = 1
61+
python-tag = "py3"

setup.cfg

Lines changed: 0 additions & 3 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 61 deletions
This file was deleted.

tests/discovery_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import unittest
2+
3+
4+
class DiscoveryTest(unittest.TestCase):
5+
def test_discovery_pass(self):
6+
pass

tests/testsuite.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,16 +796,22 @@ def test_xmlrunner_error_in_call(self):
796796
testsuite_output = self.stream.getvalue()
797797
self.assertIn('Exception: Massive fail', testsuite_output)
798798

799+
@unittest.skipIf(not unittest.BaseTestSuite._cleanup,
800+
'skip - do not cleanup')
799801
@unittest.skipIf(not hasattr(sys, 'getrefcount'),
800802
'skip - PyPy does not have sys.getrefcount.')
801803
@unittest.skipIf((3, 0) <= sys.version_info < (3, 4),
802804
'skip - test not garbage collected. '
803805
'https://bugs.python.org/issue11798.')
804806
def test_xmlrunner_hold_traceback(self):
807+
import gc
808+
805809
suite = unittest.TestSuite()
806810
suite.addTest(self.DummyRefCountTest('test_fail'))
807811
countBeforeTest = sys.getrefcount(self.DummyRefCountTest.dummy)
808812
runner = self._test_xmlrunner(suite)
813+
814+
gc.collect()
809815
countAfterTest = sys.getrefcount(self.DummyRefCountTest.dummy)
810816
self.assertEqual(countBeforeTest, countAfterTest)
811817

0 commit comments

Comments
 (0)