diff --git a/.gitignore b/.gitignore index 7b46f43..bda6cf6 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,6 @@ perl/MYMETA.json python/python_subunit.egg-info/ test-driver ar-lib +*.o +*.log +*.trs diff --git a/COPYING b/COPYING index fc6b993..f29be9e 100644 --- a/COPYING +++ b/COPYING @@ -29,6 +29,6 @@ Code that has been incorporated into Subunit from other projects will naturally be under its own license, and will retain that license. A known list of such code is maintained here: -* The runtests.py and python/subunit/tests/TestUtil.py module are GPL test +* The runtests.py and python/tests/TestUtil.py module are GPL test support modules. They are not installed by Subunit - they are only ever used on the build machine. Copyright 2004 Canonical Limited. diff --git a/MANIFEST.in b/MANIFEST.in index 4f521dc..5609031 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -18,3 +18,4 @@ exclude py-compile prune shell exclude stamp-h1 include NEWS +recursive-include python/tests *.py diff --git a/Makefile.am b/Makefile.am index 293a0fb..ec60153 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,23 +12,23 @@ EXTRA_DIST = \ c/check-subunit-0.9.3.patch \ c/check-subunit-0.9.5.patch \ c/check-subunit-0.9.6.patch \ - python/subunit/tests/__init__.py \ - python/subunit/tests/sample-script.py \ - python/subunit/tests/sample-two-script.py \ - python/subunit/tests/test_chunked.py \ - python/subunit/tests/test_details.py \ - python/subunit/tests/test_filters.py \ - python/subunit/tests/test_filter_to_disk.py \ - python/subunit/tests/test_output_filter.py \ - python/subunit/tests/test_progress_model.py \ - python/subunit/tests/test_run.py \ - python/subunit/tests/test_subunit_filter.py \ - python/subunit/tests/test_subunit_stats.py \ - python/subunit/tests/test_subunit_tags.py \ - python/subunit/tests/test_tap2subunit.py \ - python/subunit/tests/test_test_protocol.py \ - python/subunit/tests/test_test_protocol2.py \ - python/subunit/tests/test_test_results.py \ + python/tests/__init__.py \ + python/tests/sample-script.py \ + python/tests/sample-two-script.py \ + python/tests/test_chunked.py \ + python/tests/test_details.py \ + python/tests/test_filters.py \ + python/tests/test_filter_to_disk.py \ + python/tests/test_output_filter.py \ + python/tests/test_progress_model.py \ + python/tests/test_run.py \ + python/tests/test_subunit_filter.py \ + python/tests/test_subunit_stats.py \ + python/tests/test_subunit_tags.py \ + python/tests/test_tap2subunit.py \ + python/tests/test_test_protocol.py \ + python/tests/test_test_protocol2.py \ + python/tests/test_test_results.py \ python/subunit/filter_scripts/__init__.py \ python/subunit/filter_scripts/subunit_1to2.py \ python/subunit/filter_scripts/subunit2csv.py \ diff --git a/NEWS b/NEWS index 943f18d..a314699 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,14 @@ subunit release notes --------------------- +1.4.6 (UNRELEASED) +--------------------- + +IMPROVEMENTS +~~~~~~~~~~~~ + + * Stop installing tests. (Jelmer Vernooij) + 1.4.5 (2025-11-10) --------------------- diff --git a/all_tests.py b/all_tests.py index c702f55..e74c8c1 100644 --- a/all_tests.py +++ b/all_tests.py @@ -17,6 +17,7 @@ import unittest import subunit +import tests class ShellTests(subunit.ExecTestCase): @@ -29,7 +30,7 @@ def test_functions(self): def test_suite(): result = unittest.TestSuite() - result.addTest(subunit.test_suite()) + result.addTest(tests.test_suite()) result.addTest(ShellTests("test_sourcing")) result.addTest(ShellTests("test_functions")) return result diff --git a/pyproject.toml b/pyproject.toml index fce8b07..c6f3423 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,6 +5,15 @@ requires = ["iso8601", "setuptools>=61.2", "testtools"] [tool.ruff] line-length = 120 +[[tool.mypy.overrides]] +module = [ + "gi", + "gi.repository", + "junitxml", + "testscenarios", +] +ignore_missing_imports = true + [project] authors = [ { name = "Robert Collins", email = "subunit-dev@lists.launchpad.net" }, diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py index 2d5c118..f7a286b 100644 --- a/python/subunit/__init__.py +++ b/python/subunit/__init__.py @@ -175,12 +175,6 @@ def test_script_two(self): PROGRESS_POP = 3 -def test_suite(): - import subunit.tests - - return subunit.tests.test_suite() - - def join_dir(base_path, path): """ Returns an absolute path to C{path}, calculated relative to the parent diff --git a/python/subunit/v2.py b/python/subunit/v2.py index 9f7fb4e..5951491 100644 --- a/python/subunit/v2.py +++ b/python/subunit/v2.py @@ -48,7 +48,7 @@ EPOCH = datetime.datetime.fromtimestamp(0, tz=iso8601.UTC) NUL_ELEMENT = b"\0"[0] # Contains True for types for which 'nul in thing' falsely returns false. -_nul_test_broken = {} +_nul_test_broken: dict[type, bool] = {} def read_exactly(stream, size): diff --git a/python/subunit/tests/__init__.py b/python/tests/__init__.py similarity index 98% rename from python/subunit/tests/__init__.py rename to python/tests/__init__.py index 244d624..b65d9ee 100644 --- a/python/subunit/tests/__init__.py +++ b/python/tests/__init__.py @@ -26,7 +26,7 @@ _remote_exception_str_chunked = "57\r\n" + _remote_exception_str + ": boo qux\n0\r\n" -from subunit.tests import ( # noqa: E402 +from . import ( # noqa: E402 test_chunked, test_details, test_filter_to_disk, diff --git a/python/subunit/tests/sample-script.py b/python/tests/sample-script.py similarity index 87% rename from python/subunit/tests/sample-script.py rename to python/tests/sample-script.py index d042765..c902605 100755 --- a/python/subunit/tests/sample-script.py +++ b/python/tests/sample-script.py @@ -7,7 +7,7 @@ msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) if len(sys.argv) == 2: - # subunit.tests.test_test_protocol.TestExecTestCase.test_sample_method_args + # tests.test_test_protocol.TestExecTestCase.test_sample_method_args # uses this code path to be sure that the arguments were passed to # sample-script.py print("test fail") diff --git a/python/subunit/tests/sample-two-script.py b/python/tests/sample-two-script.py similarity index 100% rename from python/subunit/tests/sample-two-script.py rename to python/tests/sample-two-script.py diff --git a/python/subunit/tests/test_chunked.py b/python/tests/test_chunked.py similarity index 100% rename from python/subunit/tests/test_chunked.py rename to python/tests/test_chunked.py diff --git a/python/subunit/tests/test_details.py b/python/tests/test_details.py similarity index 100% rename from python/subunit/tests/test_details.py rename to python/tests/test_details.py diff --git a/python/subunit/tests/test_filter_to_disk.py b/python/tests/test_filter_to_disk.py similarity index 100% rename from python/subunit/tests/test_filter_to_disk.py rename to python/tests/test_filter_to_disk.py diff --git a/python/subunit/tests/test_filters.py b/python/tests/test_filters.py similarity index 100% rename from python/subunit/tests/test_filters.py rename to python/tests/test_filters.py diff --git a/python/subunit/tests/test_output_filter.py b/python/tests/test_output_filter.py similarity index 100% rename from python/subunit/tests/test_output_filter.py rename to python/tests/test_output_filter.py diff --git a/python/subunit/tests/test_progress_model.py b/python/tests/test_progress_model.py similarity index 100% rename from python/subunit/tests/test_progress_model.py rename to python/tests/test_progress_model.py diff --git a/python/subunit/tests/test_run.py b/python/tests/test_run.py similarity index 94% rename from python/subunit/tests/test_run.py rename to python/tests/test_run.py index ec3bf3b..22757a4 100644 --- a/python/subunit/tests/test_run.py +++ b/python/tests/test_run.py @@ -93,7 +93,7 @@ def test_exits_zero_when_tests_fail(self): try: self.assertEqual( None, - run.main(argv=["progName", "subunit.tests.test_run.TestSubunitTestRunner.FailingTest"], stdout=stream), + run.main(argv=["progName", "tests.test_run.TestSubunitTestRunner.FailingTest"], stdout=stream), ) except SystemExit: self.fail("SystemExit raised") @@ -109,7 +109,7 @@ def test_exits_nonzero_when_execution_errors(self): exc = self.assertRaises( SystemExit, run.main, - argv=["progName", "subunit.tests.test_run.TestSubunitTestRunner.ExitingTest"], + argv=["progName", "tests.test_run.TestSubunitTestRunner.ExitingTest"], stdout=stream, ) self.assertEqual(0, exc.args[0]) diff --git a/python/subunit/tests/test_subunit_filter.py b/python/tests/test_subunit_filter.py similarity index 100% rename from python/subunit/tests/test_subunit_filter.py rename to python/tests/test_subunit_filter.py diff --git a/python/subunit/tests/test_subunit_stats.py b/python/tests/test_subunit_stats.py similarity index 100% rename from python/subunit/tests/test_subunit_stats.py rename to python/tests/test_subunit_stats.py diff --git a/python/subunit/tests/test_subunit_tags.py b/python/tests/test_subunit_tags.py similarity index 100% rename from python/subunit/tests/test_subunit_tags.py rename to python/tests/test_subunit_tags.py diff --git a/python/subunit/tests/test_tap2subunit.py b/python/tests/test_tap2subunit.py similarity index 100% rename from python/subunit/tests/test_tap2subunit.py rename to python/tests/test_tap2subunit.py diff --git a/python/subunit/tests/test_test_protocol.py b/python/tests/test_test_protocol.py similarity index 99% rename from python/subunit/tests/test_test_protocol.py rename to python/tests/test_test_protocol.py index a8ea911..fc28c5c 100644 --- a/python/subunit/tests/test_test_protocol.py +++ b/python/tests/test_test_protocol.py @@ -32,7 +32,7 @@ import iso8601 import subunit -from subunit.tests import ( +from . import ( _remote_exception_repr, _remote_exception_repr_chunked, _remote_exception_str, diff --git a/python/subunit/tests/test_test_protocol2.py b/python/tests/test_test_protocol2.py similarity index 98% rename from python/subunit/tests/test_test_protocol2.py rename to python/tests/test_test_protocol2.py index 2874e43..7ba20c8 100644 --- a/python/subunit/tests/test_test_protocol2.py +++ b/python/tests/test_test_protocol2.py @@ -16,6 +16,8 @@ import datetime from io import BytesIO +from typing import Callable, Optional +from types import ModuleType try: from hypothesis import given @@ -25,17 +27,17 @@ # Settings.default.verbosity = Verbosity.verbose import hypothesis.strategies as st except ImportError: - given = None - st = None + given: Optional[Callable[..., Callable[..., None]]] = None # type: ignore[assignment,no-redef] + st: Optional[ModuleType] = None # type: ignore[assignment,no-redef] from testtools import TestCase from testtools.matchers import Contains, HasLength from testtools.testresult.doubles import StreamResult try: - from testtools.tests.test_testresult import TestStreamResultContract + from testtools.tests.test_testresult import TestStreamResultContract # type: ignore[import-not-found] except ImportError: # testtools >= 2.8 no longer includes the tests submodule - TestStreamResultContract = None + TestStreamResultContract: Optional[type] = None # type: ignore[assignment,misc,no-redef] import subunit import iso8601 diff --git a/python/subunit/tests/test_test_results.py b/python/tests/test_test_results.py similarity index 100% rename from python/subunit/tests/test_test_results.py rename to python/tests/test_test_results.py