diff options
author | Tomer Keren <tomer.keren.dev@gmail.com> | 2018-10-15 11:13:24 +0300 |
---|---|---|
committer | Tomer Keren <tomer.keren.dev@gmail.com> | 2018-10-15 11:13:24 +0300 |
commit | 661013c3e922c17f2dcf90a96bcc74b95a681475 (patch) | |
tree | 1ef7777f63c54104d46fef9e4a0ea0d848ca1f6a /CONTRIBUTING.rst | |
parent | 49defa28901fb951c47dafc15b8004b18d089c5e (diff) | |
download | pytest-661013c3e922c17f2dcf90a96bcc74b95a681475.tar.gz |
Add testdir examples to CONTRIBUTING guide
Hopefully Closes: #4151
Diffstat (limited to 'CONTRIBUTING.rst')
-rw-r--r-- | CONTRIBUTING.rst | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index c005c2fb2..eb36122b5 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -280,6 +280,37 @@ Here is a simple overview, with pytest-specific bits: base: features # if it's a feature +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>`_, + +For example: + +.. code-block:: python + + def test_true_assertion(testdir): + testdir.makepyfile( + """ + def test_foo(): + assert True + """ + ) + result = testdir.runpytest() + result.assert_outcomes(failed=0, passed=1) + + + def test_true_assertion(testdir): + testdir.makepyfile( + """ + def test_foo(): + assert False + """ + ) + result = testdir.runpytest() + result.assert_outcomes(failed=1, passed=0) + + Joining the Development Team ---------------------------- |