diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2020-12-08 06:48:58 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-08 06:48:58 -0800 |
commit | ef4998692c753a635eba58975ae80834dfc14538 (patch) | |
tree | f959bde2fae72c30e129520023b698a9220bbdf2 | |
parent | f655908d75010db66ec88e4023ed0982b8b00f94 (diff) | |
download | pycparser-ef4998692c753a635eba58975ae80834dfc14538.tar.gz |
Simplify test execution (#400)
Use the stdlib standard entry point for running tests through the
command:
python -m unittest discover
Docs: https://docs.python.org/3/library/unittest.html#unittest-test-discovery
This automatically looks for files with the test_ prefix and runs them
as tests. This removes the need for the custom test entry point script,
all_tests.py.
-rw-r--r-- | .github/workflows/ci.yml | 3 | ||||
-rw-r--r-- | tests/README.txt | 2 | ||||
-rw-r--r-- | tests/__init__.py | 0 | ||||
-rwxr-xr-x | tests/all_tests.py | 20 |
4 files changed, 2 insertions, 23 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 212f0bb..40c5b02 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,5 +24,4 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Test - run: | - python tests/all_tests.py + run: python -m unittest discover diff --git a/tests/README.txt b/tests/README.txt index 5196024..c540b7b 100644 --- a/tests/README.txt +++ b/tests/README.txt @@ -1 +1 @@ -Run 'python tests/all_tests.py' from the root pycparser directory +Run 'python -m unittest discover' from the root pycparser directory diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/__init__.py diff --git a/tests/all_tests.py b/tests/all_tests.py deleted file mode 100755 index 74761b6..0000000 --- a/tests/all_tests.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python - -import sys -sys.path[0:0] = ['.', '..'] - -import unittest - - -suite = unittest.TestLoader().loadTestsFromNames( - [ - 'test_c_lexer', - 'test_c_ast', - 'test_general', - 'test_c_parser', - 'test_c_generator', - ] -) - -testresult = unittest.TextTestRunner(verbosity=1).run(suite) -sys.exit(0 if testresult.wasSuccessful() else 1) |