diff options
Diffstat (limited to 'doc/rtd/topics/testing.rst')
-rw-r--r-- | doc/rtd/topics/testing.rst | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/doc/rtd/topics/testing.rst b/doc/rtd/topics/testing.rst index 7a1e3eec..5543c6f5 100644 --- a/doc/rtd/topics/testing.rst +++ b/doc/rtd/topics/testing.rst @@ -54,28 +54,22 @@ Test Layout * pytest tests should use bare ``assert`` statements, to take advantage of pytest's `assertion introspection`_ - * For ``==`` and other commutative assertions, the expected value - should be placed before the value under test: - ``assert expected_value == function_under_test()`` - - ``pytest`` Version Gotchas -------------------------- -As we still support Ubuntu 16.04 (Xenial Xerus), we can only use pytest -features that are available in v2.8.7. This is an inexhaustive list of +As we still support Ubuntu 18.04 (Bionic Beaver), we can only use pytest +features that are available in v3.3.2. This is an inexhaustive list of ways in which this may catch you out: -* Support for using ``yield`` in ``pytest.fixture`` functions was only - introduced in `pytest 3.0`_. Such functions must instead use the - ``pytest.yield_fixture`` decorator. - * Only the following built-in fixtures are available [#fixture-list]_: * ``cache`` * ``capfd`` - * ``caplog`` (provided by ``python3-pytest-catchlog`` on xenial) + * ``capfdbinary`` + * ``caplog`` * ``capsys`` + * ``capsysbinary`` + * ``doctest_namespace`` * ``monkeypatch`` * ``pytestconfig`` * ``record_xml_property`` @@ -83,22 +77,6 @@ ways in which this may catch you out: * ``tmpdir_factory`` * ``tmpdir`` -* On xenial, the objects returned by the ``tmpdir`` fixture cannot be - used where paths are required; they are rejected as invalid paths. - You must instead use their ``.strpath`` attribute. - - * For example, instead of ``util.write_file(tmpdir.join("some_file"), - ...)``, you should write - ``util.write_file(tmpdir.join("some_file").strpath, ...)``. - -* The `pytest.param`_ function cannot be used. It was introduced in - pytest 3.1, which means it is not available on xenial. The more - limited mechanism it replaced was removed in pytest 4.0, so is not - available in focal or later. The only available alternatives are to - write mark-requiring test instances as completely separate tests, - without utilising parameterisation, or to apply the mark to the - entire parameterized test (and therefore every test instance). - Mocking and Assertions ---------------------- @@ -168,9 +146,9 @@ Test Argument Ordering .. [#fixture-list] This list of fixtures (with markup) can be reproduced by running:: - py.test-3 --fixtures -q | grep "^[^ -]" | grep -v '\(no\|capturelog\)' | sort | sed 's/.*/* ``\0``/' + python3 -m pytest --fixtures -q | grep "^[^ -]" | grep -v 'no tests ran in' | sort | sed 's/ \[session scope\]//g;s/.*/* ``\0``/g' - in a xenial lxd container with python3-pytest-catchlog installed. + in an ubuntu lxd container with python3-pytest installed. .. _pytest: https://docs.pytest.org/ .. _pytest fixtures: https://docs.pytest.org/en/latest/fixture.html |