You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.rst
+38-8Lines changed: 38 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -19,9 +19,9 @@ Reviewing and merging pull requests is work, so whatever you can do to make this
19
19
easier for the package maintainer not only speed up the process of getting your
20
20
changes merged but also ensure they are. These few guidelines help significantly.
21
21
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.
23
23
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.
25
25
- Please do make sure that both your pull request description and your commits are meaningful and descriptive. Rebase first, if need be.
26
26
- Please do make sure your changeset does not include more commits than necessary. Rebase first, if need be.
27
27
- 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.
30
30
Testing
31
31
=======
32
32
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/>`_::
34
51
35
52
pip install tox
36
-
detox
53
+
tox
37
54
38
55
Or it's slightly faster cousin `detox
39
56
<https://pypi.python.org/pypi/detox>`_ which will parallelize test runs::
40
57
41
58
pip install detox
42
59
detox
43
60
44
-
Alternatively, you can run the self test with the following commands::
61
+
Writing tests
62
+
-------------
45
63
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.
49
78
50
79
Live Testing
51
80
============
52
81
53
82
You can test against a Discourse instance by following the [Official Discourse developement instructions][discoursedev].
83
+
54
84
For the impatient here is the quick and dirty version::
0 commit comments