diff options
author | Bruno Oliveira <nicoddemus@gmail.com> | 2018-10-15 08:00:16 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-15 08:00:16 -0300 |
commit | f129ba617f8d481ba8469f2e039a574c8717b312 (patch) | |
tree | 960b7640400fa6ba81acd8a6ee2a1c465da18502 /CONTRIBUTING.rst | |
parent | 99d957bd3df2bd4fcb4a4603a2073d6fc448b1e6 (diff) | |
download | pytest-f129ba617f8d481ba8469f2e039a574c8717b312.tar.gz |
Improve docs a bit
Diffstat (limited to 'CONTRIBUTING.rst')
-rw-r--r-- | CONTRIBUTING.rst | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index eb36122b5..c8ef03209 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -283,9 +283,9 @@ Here is a simple overview, with pytest-specific bits: Writing Tests ---------------------------- -Writing tests for plugins or for pytest itself is done using the `testdir fixture <https://docs.pytest.org/en/latest/reference.html#testdir>`_, +Writing tests for plugins or for pytest itself is often done using the `testdir fixture <https://docs.pytest.org/en/latest/reference.html#testdir>`_, as a "black-box" test. -For example: +For example, to ensure a simple test passes you can write: .. code-block:: python @@ -300,6 +300,11 @@ For example: result.assert_outcomes(failed=0, passed=1) +Alternatively, it is possible to make checks based on the actual output of the termal using +*glob-like* expressions: + +.. code-block:: python + def test_true_assertion(testdir): testdir.makepyfile( """ @@ -308,7 +313,12 @@ For example: """ ) result = testdir.runpytest() - result.assert_outcomes(failed=1, passed=0) + result.stdout.fnmatch_lines(["*assert False*, "*1 failed*"]) + +When choosing a file where to write a new test, take a look at the existing files and see if there's +one file which looks like a good fit. For example, a regression test about a bug in the ``--lf`` option +should go into ``test_cacheprovider.py``, given that this option is implemented in ``cacheprovider.py``. +If in doubt, go ahead and open a PR with your best guess and we can discuss this over the code. Joining the Development Team |