Skip to content

Commit 28eab68

Browse files
committed
Fix tests invocation across CI
Employ unittest discovery CLI, fix (sometimes) broken import.
1 parent 089f6cb commit 28eab68

File tree

5 files changed

+22
-23
lines changed

5 files changed

+22
-23
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ jobs:
118118
# This is needed for now because cffi has no cp310 wheels
119119
CIBW_BEFORE_ALL_LINUX: "yum -y install libffi-devel"
120120
CIBW_TEST_EXTRAS: "test"
121-
CIBW_TEST_COMMAND: "python {project}/tests/__init__.py"
122-
CIBW_TEST_COMMAND_WINDOWS: "python {project}\\tests\\__init__.py"
121+
CIBW_TEST_COMMAND: "python -m unittest discover -v {project}/tests"
122+
CIBW_TEST_COMMAND_WINDOWS: "python -m unittest discover -v {project}\\tests"
123123
CIBW_TEST_SKIP: "*universal2:arm64"
124124

125125
- uses: actions/upload-artifact@v3

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ docs:
4747

4848

4949
test:
50-
PYTHONASYNCIODEBUG=1 $(PYTHON) -m unittest -v tests.suite
51-
$(PYTHON) -m unittest -v tests.suite
50+
PYTHONASYNCIODEBUG=1 $(PYTHON) -m unittest discover -v tests
51+
$(PYTHON) -m unittest discover -v tests
5252

5353

5454
testinstalled:
55-
cd "$${HOME}" && $(PYTHON) $(ROOT)/tests/__init__.py
55+
cd "$${HOME}" && $(PYTHON) -m unittest discover -v $(ROOT)/tests

tests/__init__.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +0,0 @@
1-
import os.path
2-
import sys
3-
import unittest
4-
import unittest.runner
5-
6-
7-
def suite():
8-
test_loader = unittest.TestLoader()
9-
test_suite = test_loader.discover(
10-
os.path.dirname(__file__), pattern='test_*.py')
11-
return test_suite
12-
13-
14-
if __name__ == '__main__':
15-
runner = unittest.runner.TextTestRunner()
16-
result = runner.run(suite())
17-
sys.exit(not result.wasSuccessful())

tests/__main__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os.path
2+
import sys
3+
import unittest
4+
import unittest.runner
5+
6+
7+
def suite():
8+
test_loader = unittest.TestLoader()
9+
test_suite = test_loader.discover(os.path.dirname(__file__))
10+
return test_suite
11+
12+
13+
if __name__ == '__main__':
14+
runner = unittest.runner.TextTestRunner()
15+
result = runner.run(suite())
16+
sys.exit(not result.wasSuccessful())

tests/test_libuv_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_libuv_get_loop_t_ptr(self):
1313

1414
pyximport.install()
1515

16-
from tests import cython_helper
16+
import cython_helper
1717

1818
self.assertTrue(cython_helper.capsule_equals(cap1, cap2))
1919
self.assertFalse(cython_helper.capsule_equals(cap1, cap3))

0 commit comments

Comments
 (0)