Skip to content

Commit

Permalink
Remove usage of QiskitTestCase
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wshanks committed Nov 2, 2023
1 parent 12a71b9 commit 7a81d8e
Show file tree
Hide file tree
Showing 4 changed files with 269 additions and 189 deletions.
4 changes: 3 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
black~=22.0
fixtures
stestr
testtools
pylint~=2.16.2
astroid~=2.14.2 # Must be kept aligned to what pylint wants
jinja2==3.0.3
Expand All @@ -20,4 +22,4 @@ coverage>=5.5
ipykernel<=6.21.3
jupyter-client<=8.0.3
ipython<8.13.0 ; python_version<"3.9" # for python 3.8 compatibility
sphinx-remove-toctrees
sphinx-remove-toctrees
Loading

0 comments on commit 7a81d8e

Please sign in to comment.