Skip to content

Commit

Permalink
Add description of test variables to contributing guide
Browse files Browse the repository at this point in the history
  • Loading branch information
wshanks committed Nov 8, 2023
1 parent e1eb8df commit e6643cf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ Note that tests will fail automatically if they do not finish execution within 6

#### STDOUT/STDERR and logging capture

When running tests in parallel using `stestr` either via tox, the Makefile (`make
test_ci`), or in CI, we set the env variable `QISKIT_TEST_CAPTURE_STREAMS`, which will
When running tests in parallel using `stestr` either via tox
or in CI, we set the env variable `QISKIT_TEST_CAPTURE_STREAMS`, which will
capture any text written to stdout, stderr, and log messages and add them as attachments
to the tests run so output can be associated with the test case it originated from.
However, if you run tests with `stestr` outside of these mechanisms, by default the
Expand All @@ -138,6 +138,18 @@ stdlib unittest runner, a similar result can be accomplished by using the
[`--buffer`](https://docs.python.org/3/library/unittest.html#command-line-options)
option (e.g. `python -m unittest discover --buffer ./test/python`).

#### Other testing related settings

The test code defines some environment variables that may occasionally be useful to set:

+ `TEST_TIMEOUT`: An integer representing the maximum time a test can take
before it is considered a failure.
+ `QE_USE_TESTTOOLS`: Set this variable to `FALSE`, `0`, or `NO` to have the
tests use `unittest.TestCase` as the base class. Otherwise, the default is
`testtools.TestCase` which is an extension of `unittest.TestCase`. In some
situations, a developer may wish to use a workflow that is not compatible with
the `testtools` extensions.

### Code style

The qiskit-experiments repository uses `black` for code formatting and style and
Expand Down
2 changes: 1 addition & 1 deletion test/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# 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.
USE_TESTTOOLS = os.environ.get("QE_USE_TESTTOOLS", "TRUE").lower() not in ("false", "0")
USE_TESTTOOLS = os.environ.get("QE_USE_TESTTOOLS", "TRUE").lower() not in ("false", "0", "no")


def create_base_test_case(use_testtools: bool) -> unittest.TestCase:
Expand Down

0 comments on commit e6643cf

Please sign in to comment.