Skip to content

Commit be0515d

Browse files
Revert "Merge pull request plotly#5010 from plotly/more-cleanup"
This reverts commit 86a7e12, reversing changes made to 5813a8a.
1 parent 86a7e12 commit be0515d

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 88

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
repos:
2+
- repo: https://github.com/ambv/black
3+
rev: 22.3.0
4+
hooks:
5+
- id: black
6+
language_version: python

contributing.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,10 @@ $ python setup.py updateplotlyjsdev --local /path/to/your/plotly.js/
254254

255255
## Testing
256256

257-
To run tests, we use [`pytest`](https://docs.pytest.org/en/latest/), a powerful framework for unit testing.
257+
We take advantage of two tools to run tests:
258+
259+
* [`tox`](https://tox.readthedocs.io/en/latest/), which is both a virtualenv management and test tool.
260+
* [`pytest`](https://docs.pytest.org/en/latest/), a powerful framework for unit testing.
258261

259262
### Running Tests with `pytest`
260263

@@ -290,8 +293,51 @@ or for a specific test function
290293
pytest plotly/tests/test_plotly/test_plot.py::test_function
291294
```
292295

296+
### Running tests with `tox`
297+
298+
Running tests with tox is much more powerful, but requires a bit more setup.
299+
300+
You'll need to export an environment variable for *each* tox environment you wish to test with. For example, if you want to test with `Python 3.9` and
301+
`Python 3.6`, but only care to check the `core` specs, you would need to ensure that the following variables are exported:
302+
303+
```
304+
export PLOTLY_TOX_PYTHON_39=<python binary>
305+
export PLOTLY_TOX_PYTHON_36=<python binary>
306+
```
307+
308+
Where the `<python binary` is going to be specific to your development setup. As a more complete example, you might have this loaded in a `.bash_profile` (or equivalent shell loader):
309+
310+
```bash
311+
############
312+
# tox envs #
313+
############
314+
315+
export PLOTLY_TOX_PYTHON_39=python3.9
316+
export PLOTLY_TOX_PYTHON_36=python3.6
317+
export TOXENV=py39-core,py36-core
318+
```
319+
320+
Where `TOXENV` is the environment list you want to use when invoking `tox` from the command line. Note that the `PLOTLY_TOX_*` pattern is used to pass in variables for use in the `tox.ini` file. Though this is a little setup, intensive, you'll get the following benefits:
321+
322+
* `tox` will automatically manage a virtual env for each environment you want to test in.
323+
* You only have to run `tox` and know that the module is working in all included Python versions.
324+
325+
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 `pytest.ini`. To run only tests that are *not* tagged with `nodev`, you could use the following command:
326+
327+
```bash
328+
tox -- -a '!nodev'
329+
```
330+
331+
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:
332+
333+
```bash
334+
tox -- -a '!nodev','!matplotlib'
335+
```
336+
293337
### Writing Tests
294338

295339
You're *strongly* encouraged to write tests that check your added functionality.
296340

297341
When you write a new test anywhere under the `tests` directory, if your PR gets accepted, that test will run in a virtual machine to ensure that future changes don't break your contributions!
342+
343+
Test accounts include: `PythonTest`, `PlotlyImageTest`, and `PlotlyStageTest`.

0 commit comments

Comments
 (0)