Skip to content

Commit 5c4d0b3

Browse files
committed
Update contributing about tests
1 parent f20fc33 commit 5c4d0b3

File tree

1 file changed

+38
-8
lines changed

1 file changed

+38
-8
lines changed

CONTRIBUTING.rst

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ Reviewing and merging pull requests is work, so whatever you can do to make this
1919
easier for the package maintainer not only speed up the process of getting your
2020
changes merged but also ensure they are. These few guidelines help significantly.
2121
If they are confusing or you need help understanding how to accomplish them,
22-
please ask for help in an issue.
22+
please ask for help in an issue.
2323

24-
- Please do make sure your chnageset represents a *discrete update*. If you would like to fix formatting, by all means, but don't mix that up with a bug fix. Those are separate PRs.
24+
- Please do make sure your changeset represents a *discrete update*. If you would like to fix formatting, by all means, but don't mix that up with a bug fix. Those are separate PRs.
2525
- Please do make sure that both your pull request description and your commits are meaningful and descriptive. Rebase first, if need be.
2626
- Please do make sure your changeset does not include more commits than necessary. Rebase first, if need be.
2727
- Please do make sure the changeset is not very big. If you have a large change propose it in an issue first.
@@ -30,27 +30,57 @@ please ask for help in an issue.
3030
Testing
3131
=======
3232

33-
The best way to run the tests is with `tox <http://tox.readthedocs.org/en/latest/>`_::
33+
Running tests
34+
-------------
35+
36+
The simplest way to quickly and repeatedly run tests while developing a feature or fix
37+
is to use `pytest` in your current Python environment.
38+
39+
After installing the test dependencies::
40+
41+
pip install -r requirements.txt
42+
pip install -e .
43+
44+
Your can run the tests with `pytest`::
45+
46+
pytest --cov=src/pydiscourse
47+
48+
This will ensure you get coverage reporting.
49+
50+
The most comprehensive way to run the tests is with `tox <http://tox.readthedocs.org/en/latest/>`_::
3451

3552
pip install tox
36-
detox
53+
tox
3754

3855
Or it's slightly faster cousin `detox
3956
<https://pypi.python.org/pypi/detox>`_ which will parallelize test runs::
4057

4158
pip install detox
4259
detox
4360

44-
Alternatively, you can run the self test with the following commands::
61+
Writing tests
62+
-------------
4563

46-
pip install -r requirements.txt
47-
pip install -e .
48-
python setup.py test
64+
The primary modules of the library have coverage requirements, so you should
65+
write a test or tests when you add a new feature.
66+
67+
**At a bare minimum a test should show which Discourse API endpoint is called,
68+
using which HTTP method, and returning any necessary data for the new function/method.**
69+
70+
In most cases this can be accomplished quite simply by using the `discourse_request`
71+
fixture, which allows for mocking the HTTP request in the `requests` library. In some cases
72+
this may be insufficient, and you may want to directly use the `requests_mock` mocking
73+
fixture.
74+
75+
If in the course of writing your test you see a `requests_mock.NoMockAddress` exception
76+
raised then either the *method* or the *path* (including querystring) - or both! - in
77+
either your mock OR your new API client method is incorrect.
4978

5079
Live Testing
5180
============
5281

5382
You can test against a Discourse instance by following the [Official Discourse developement instructions][discoursedev].
83+
5484
For the impatient here is the quick and dirty version::
5585

5686
git clone [email protected]:discourse/discourse.git

0 commit comments

Comments
 (0)