Skip to content

Commit

Permalink
Makefile: Don't use 'setup.py test' to run unittests
Browse files Browse the repository at this point in the history
Setuptools v72 deprecated the 'setup.py test' command, so stop using that for
running tests. Instead, execute the 'unittest' module directly, using our
protocol to pass the test suite name as an environment variable to the module
test loader.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
  • Loading branch information
tohojo committed Sep 10, 2024
1 parent 7174d01 commit 75d4385
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ build: flent/*.py

.PHONY: test
test:
$(PYTHON) setup.py test -r unittests:TestRunner
$(PYTHON) -m unittest

.PHONY: test_long
test_long:
$(PYTHON) setup.py test -s unittests.all_tests -r unittests:TestRunner
TEST_SUITE=all_tests $(PYTHON) -m unittest


.PHONY: install
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
[bdist_wheel]
universal=1
[test]
test_suite=unittests.test_suite
[flake8]
exclude=doc,build,dist,__pycache__,.git
max-line-length=82
Expand Down
16 changes: 10 additions & 6 deletions unittests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

from __future__ import absolute_import, division, print_function, unicode_literals

import os
import unittest
from . import test_util
from . import test_formatters
Expand All @@ -31,12 +32,6 @@
from . import test_gui


class TestRunner(unittest.TextTestRunner):
def __init__(self, *args, **kwargs):
kwargs['verbosity'] = 2
super(TestRunner, self).__init__(*args, **kwargs)


test_suite = unittest.TestSuite([test_util.test_suite,
test_formatters.test_suite,
test_metadata.test_suite,
Expand All @@ -47,3 +42,12 @@ def __init__(self, *args, **kwargs):
])

all_tests = unittest.TestSuite([test_suite, test_plotters.plot_suite])

def load_tests(loader, standard_tests, pattern):
suite = os.getenv("TEST_SUITE", None)
if suite == "all_tests":
return all_tests
return test_suite

if __name__ == "__main__":
unittest.main(verbosity=2)

0 comments on commit 75d4385

Please sign in to comment.