From d6a2b597fbefb8f2770f457a7f04c6b5c12d468b Mon Sep 17 00:00:00 2001 From: Ben Raz Date: Sat, 10 Sep 2022 18:45:27 +0300 Subject: [PATCH] Fix tests invocation on release CI worklow (#489) * Employ unittest discovery CLI (back again) * Fix (sometimes) broken import with the pyx_import * Bump cibuildwheel to 2.9.0 * Build without libffi-devel Co-authored-by: Fantix King --- .github/workflows/release.yml | 8 +++----- Makefile | 6 +++--- tests/__init__.py | 17 ----------------- tests/__main__.py | 16 ++++++++++++++++ tests/test_libuv_api.py | 2 +- 5 files changed, 23 insertions(+), 26 deletions(-) create mode 100644 tests/__main__.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 967c9ca0..8706c786 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -110,16 +110,14 @@ jobs: run: | brew install gnu-sed libtool autoconf automake - - uses: pypa/cibuildwheel@v2.8.0 + - uses: pypa/cibuildwheel@v2.9.0 env: CIBW_BUILD_VERBOSITY: 1 CIBW_BUILD: ${{ matrix.cibw_python }} CIBW_ARCHS: ${{ matrix.cibw_arch }} - # This is needed for now because cffi has no cp310 wheels - CIBW_BEFORE_ALL_LINUX: "yum -y install libffi-devel" CIBW_TEST_EXTRAS: "test" - CIBW_TEST_COMMAND: "python {project}/tests/__init__.py" - CIBW_TEST_COMMAND_WINDOWS: "python {project}\\tests\\__init__.py" + CIBW_TEST_COMMAND: "python -m unittest discover -v {project}/tests" + CIBW_TEST_COMMAND_WINDOWS: "python -m unittest discover -v {project}\\tests" CIBW_TEST_SKIP: "*universal2:arm64" - uses: actions/upload-artifact@v3 diff --git a/Makefile b/Makefile index 51c5f8c6..4375e5d2 100644 --- a/Makefile +++ b/Makefile @@ -47,9 +47,9 @@ docs: test: - PYTHONASYNCIODEBUG=1 $(PYTHON) -m unittest -v tests.suite - $(PYTHON) -m unittest -v tests.suite + PYTHONASYNCIODEBUG=1 $(PYTHON) -m unittest discover -v tests + $(PYTHON) -m unittest discover -v tests testinstalled: - cd "$${HOME}" && $(PYTHON) $(ROOT)/tests/__init__.py + cd "$${HOME}" && $(PYTHON) -m unittest discover -v $(ROOT)/tests diff --git a/tests/__init__.py b/tests/__init__.py index 0f18e3f6..e69de29b 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,17 +0,0 @@ -import os.path -import sys -import unittest -import unittest.runner - - -def suite(): - test_loader = unittest.TestLoader() - test_suite = test_loader.discover( - os.path.dirname(__file__), pattern='test_*.py') - return test_suite - - -if __name__ == '__main__': - runner = unittest.runner.TextTestRunner() - result = runner.run(suite()) - sys.exit(not result.wasSuccessful()) diff --git a/tests/__main__.py b/tests/__main__.py new file mode 100644 index 00000000..9db8f501 --- /dev/null +++ b/tests/__main__.py @@ -0,0 +1,16 @@ +import os.path +import sys +import unittest +import unittest.runner + + +def suite(): + test_loader = unittest.TestLoader() + test_suite = test_loader.discover(os.path.dirname(__file__)) + return test_suite + + +if __name__ == '__main__': + runner = unittest.runner.TextTestRunner() + result = runner.run(suite()) + sys.exit(not result.wasSuccessful()) diff --git a/tests/test_libuv_api.py b/tests/test_libuv_api.py index d0db5180..3cda4bcd 100644 --- a/tests/test_libuv_api.py +++ b/tests/test_libuv_api.py @@ -13,7 +13,7 @@ def test_libuv_get_loop_t_ptr(self): pyximport.install() - from tests import cython_helper + import cython_helper self.assertTrue(cython_helper.capsule_equals(cap1, cap2)) self.assertFalse(cython_helper.capsule_equals(cap1, cap3))