Skip to content

Commit

Permalink
Adjust testtools usage
Browse files Browse the repository at this point in the history
  • Loading branch information
wshanks committed Oct 18, 2023
1 parent 2454670 commit 5e2b5d2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 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
20 changes: 12 additions & 8 deletions test/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
from typing import Any, Callable, Optional

import fixtures
import testtools
import uncertainties
from qiskit.utils.deprecation import deprecate_func

import qiskit_experiments.warnings
from qiskit_experiments.framework import (
ExperimentDecoder,
ExperimentEncoder,
Expand All @@ -35,14 +35,14 @@
from .extended_equality import is_equivalent

# Fail tests that take longer than this
TEST_TIMEOUT = os.environ.get("TEST_TIMEOUT", 60)


# If testtools is installed use that as a (mostly) drop in replacement for
TEST_TIMEOUT = int(os.environ.get("TEST_TIMEOUT", 60))
# Use testtools by default as a (mostly) drop in replacement for
# unittest's TestCase. This will enable the fixtures used for capturing stdout
# stderr, and pylogging to attach the output to stestr's result stream.
if qiskit_experiments.warnings.HAS_TESTTOOLS:
import testtools
USE_TESTTOOLS = os.environ.get("QE_USE_TESTOOLS", "TRUE") == "TRUE"


if USE_TESTTOOLS:

class BaseTestCase(testtools.TestCase):
"""Base test class."""
Expand All @@ -61,7 +61,11 @@ class BaseTestCase(testtools.TestCase):
class BaseTestCase(unittest.TestCase):
"""Base test class."""

pass
def useFixture(self, fixture):
"""Shim so that useFixture can be called in subclasses
The actual fixture is not used when using unittest.
"""


# TODO: copy enforce_subclasses_call decorator?
Expand Down

0 comments on commit 5e2b5d2

Please sign in to comment.