|
1 | 1 | # Contributing
|
2 | 2 |
|
3 |
| -The bottom line. Follow your Nose, or our Nose. Write-run-love tests :fist:. |
| 3 | +Thank you for contributing to plotly.py! |
4 | 4 |
|
5 | 5 | ## Code of Conduct
|
6 | 6 |
|
@@ -128,34 +128,40 @@ classes based on the new schema.
|
128 | 128 | We take advantage of two tools to run tests:
|
129 | 129 |
|
130 | 130 | * [`tox`](https://tox.readthedocs.io/en/latest/), which is both a virtualenv management and test tool.
|
131 |
| -* [`nose`](https://nose.readthedocs.org/en/latest/), which is is an extension of Python's unittest |
| 131 | +* [`pytest`](https://docs.pytest.org/en/latest/), a powerful framework for unit testing. |
132 | 132 |
|
133 |
| -### Running Tests with `nose` |
| 133 | +### Running Tests with `pytest` |
134 | 134 |
|
135 | 135 | Since our tests cover *all* the functionality, to prevent tons of errors from showing up and having to parse through a messy output, you'll need to install `optional-requirements.txt` as explained above.
|
136 | 136 |
|
137 |
| -After you've done that, go ahead and follow (y)our Nose! |
| 137 | +After you've done that, go ahead and run the test suite! |
138 | 138 |
|
139 | 139 | ```bash
|
140 |
| -nosetests -w packages/python/plotly/plotly/tests/ |
| 140 | +pytest packages/python/plotly/plotly/tests/ |
141 | 141 | ```
|
142 | 142 |
|
143 | 143 | Or for more *verbose* output:
|
144 | 144 |
|
145 | 145 | ```bash
|
146 |
| -nosetests -w packages/python/plotly/plotly/tests/ -v |
| 146 | +pytest -v packages/python/plotly/plotly/tests/ |
147 | 147 | ```
|
148 | 148 |
|
149 | 149 | Either of those will run *every* test we've written for the Python API. You can get more granular by running something like:
|
150 | 150 |
|
151 | 151 | ```bash
|
152 |
| -nosetests -w packages/python/plotly/plotly/tests/test_core/ |
| 152 | +pytest packages/python/plotly/plotly/tests/test_core/ |
153 | 153 | ```
|
154 | 154 |
|
155 | 155 | ... or even more granular by running something like:
|
156 | 156 |
|
157 | 157 | ```bash
|
158 |
| -nosetests plotly/tests/test_plotly/test_plot.py |
| 158 | +pytest plotly/tests/test_plotly/test_plot.py |
| 159 | +``` |
| 160 | + |
| 161 | +or for a specfic test function |
| 162 | + |
| 163 | +```bash |
| 164 | +pytest plotly/tests/test_plotly/test_plot.py::test_function |
159 | 165 | ```
|
160 | 166 |
|
161 | 167 | ### Running tests with `tox`
|
@@ -187,16 +193,16 @@ Where `TOXENV` is the environment list you want to use when invoking `tox` from
|
187 | 193 | * `tox` will automatically manage a virtual env for each environment you want to test in.
|
188 | 194 | * You only have to run `tox` and know that the module is working in both `Python 2` and `Python 3`.
|
189 | 195 |
|
190 |
| -Finally, `tox` allows you to pass in additional command line arguments that are formatted in (by us) in the `tox.ini` file, see `{posargs}`. This is setup to help with our `nose attr` configuration. To run only tests that are *not* tagged with `slow`, you could use the following command: |
| 196 | +Finally, `tox` allows you to pass in additional command line arguments that are formatted in (by us) in the `tox.ini` file, see `{posargs}`. This is setup to help with our configuration of [pytest markers](http://doc.pytest.org/en/latest/example/markers.html), which are set up in `packages/python/plotly/pytest.ini`. To run only tests that are *not* tagged with `nodev`, you could use the following command: |
191 | 197 |
|
192 | 198 | ```bash
|
193 |
| -tox -- -a '!slow' |
| 199 | +tox -- -a '!nodev' |
194 | 200 | ```
|
195 | 201 |
|
196 |
| -Note that anything after `--` is substituted in for `{posargs}` in the tox.ini. For completeness, because it's reasonably confusing, if you want to force a match for *multiple* `nose attr` tags, you comma-separate the tags like so: |
| 202 | +Note that anything after `--` is substituted in for `{posargs}` in the tox.ini. For completeness, because it's reasonably confusing, if you want to force a match for *multiple* `pytest` marker tags, you comma-separate the tags like so: |
197 | 203 |
|
198 | 204 | ```bash
|
199 |
| -tox -- -a '!slow','!matplotlib' |
| 205 | +tox -- -a '!nodev','!matplotlib' |
200 | 206 | ```
|
201 | 207 |
|
202 | 208 | ### Writing Tests
|
|
0 commit comments