Skip to content

Commit 7a81d8e

Browse files
committed
Remove usage of QiskitTestCase
This change removes the dependence on `QiskitTestCase`, replacing it with a direct dependence on `unittest.TestCase` and `testtools.TestCase`. As with `QiskitTestCase`, the ability to run the tests based either on `unittest.TestCase` or `testtools.TestCase` (a `unittest.TestCase` subclass) is preserved. For qiskit-experiments, the ability is actually restored because the timeout feature added in [#1246](#1246) had introduced a hard dependence on `testtools`. Specific changes: * Add `testtools` and `fixtures` to `requirements-dev.txt` as required test dependencies. * Use `QE_USE_TESTTOOLS` environment variable to control whether tests are based on `testtools.TestCase` rather than checking if `testtools` is installed. * Remove some checks for test writing best practices. `QiskitTestCase` used extra code to ensure that `setUp` and other test class methods always called their parents and that those methods are not called from individual tests. `testtools.TestCase` does these checks as well. Since qiskit-experiments always uses `testtools` in CI, it can rely on `testtools` for these checks and just not do them for the alternate `unittest` execution. * Generate `QiskitExperimentsTestCase` from a `create_base_test_case` function. This function allows the base test class to be generated based on either `testtools.TestCase` or `unittest.TestCase` so that the `unittest` variant can be tested for regressions even when the `testtools` variant is enabled.
1 parent 12a71b9 commit 7a81d8e

File tree

4 files changed

+269
-189
lines changed

4 files changed

+269
-189
lines changed

requirements-dev.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
black~=22.0
2+
fixtures
23
stestr
4+
testtools
35
pylint~=2.16.2
46
astroid~=2.14.2 # Must be kept aligned to what pylint wants
57
jinja2==3.0.3
@@ -20,4 +22,4 @@ coverage>=5.5
2022
ipykernel<=6.21.3
2123
jupyter-client<=8.0.3
2224
ipython<8.13.0 ; python_version<"3.9" # for python 3.8 compatibility
23-
sphinx-remove-toctrees
25+
sphinx-remove-toctrees

0 commit comments

Comments
 (0)