Skip to content

Commit c6978f4

Browse files
committed
Merge pull request #1450 from rtfd/tox-test-and-lint
Linting and starting to use Tox
2 parents 1e21c78 + 1349be5 commit c6978f4

File tree

5 files changed

+121
-24
lines changed

5 files changed

+121
-24
lines changed

.travis.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
language: python
22
python:
3-
- "2.7"
3+
- 2.7
44
sudo: false
5+
env:
6+
- TOX_ENV=py27
7+
- TOX_ENV=docs
8+
#- TOX_ENV=lint
59
install:
6-
- pip install flake8 stripe
7-
- pip install -r requirements.txt
10+
- pip install tox
811
- pip install coveralls
912
script:
10-
#- flake8 `find . -iname "*.py" -not -ipath "*migration*"`
11-
- ./runtests.sh
13+
- tox -e $TOX_ENV
1214
after_success:
1315
- coveralls
1416
notifications:

docs/tests.rst

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,44 @@
1-
Running tests
2-
=============
1+
Testing
2+
=======
33

4-
Read the Docs ships with a test suite that tests the application. You should run these tests when you are doing development before committing code.
4+
Before contributing to Read the Docs, make sure your patch passes our test suite
5+
and your code style passes our code linting suite.
56

6-
They can be run easily::
7+
Read the Docs uses `Tox`_ to execute testing and linting procedures. Tox is the
8+
only dependency you need to run linting or our test suite, the remainder of our
9+
requirements will be installed by Tox into environment specific virtualenv
10+
paths. Before testing, make sure you have Tox installed::
711

8-
pip install coverage
9-
./runtests.sh
12+
pip install tox
1013

11-
This should print out a bunch of information and pass with 0 errors.
14+
To run the full test and lint suite against your changes, simply run Tox. Tox
15+
should return without any errors. You can run Tox against all of our
16+
environments by running::
17+
18+
tox
19+
20+
To target a specific environment::
21+
22+
tox -e py27
23+
24+
The ``tox`` configuration has the following environments configured. You can
25+
target a single environment to limit the test suite::
26+
27+
py27
28+
Run our test suite using Python 2.7
29+
30+
lint
31+
Run code linting using `Prospector`_. This currently runs `pylint`_,
32+
`pyflakes`_, `pep8`_ and other linting tools.
33+
34+
docs
35+
Test documentation compilation with Sphinx.
36+
37+
.. _`Tox`: http://tox.readthedocs.org/en/latest/index.html
38+
.. _`Prospector`: http://prospector.readthedocs.org/en/master/
39+
.. _`pylint`: http://docs.pylint.org/
40+
.. _`pyflakes`: https://github.com/pyflakes/pyflakes
41+
.. _`pep8`: http://pep8.readthedocs.org/en/latest/index.html
1242

1343
Continuous Integration
1444
----------------------

prospector.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
strictness: low
2+
3+
test-warnings: false
4+
doc-warnings: true
5+
6+
uses:
7+
- django
8+
- celery
9+
10+
ignore-paths:
11+
- projects
12+
- builds
13+
- docs
14+
15+
ignore-patterns:
16+
- /migrations/
17+
18+
pep8:
19+
full: true
20+
options:
21+
max-line-length: 100
22+
23+
pylint:
24+
max-line-length: 100
25+
26+
mccabe:
27+
run: false
28+
29+
pep257:
30+
run: false

readthedocs/rtd_tests/tests/test_project_symlinks.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ def test_symlink_basic(self):
5858
'ln -nsf {translation}/rtd-builds {project}/translations/de',
5959
'ln -nsf {builds} {project}/translations/en',
6060
]
61-
for (i, command) in enumerate(commands):
62-
self.assertEqual(self.commands[i], command.format(**self.args),
63-
msg=('Command {0} mismatch, expecting {1}'
64-
.format(i, self.commands[i])))
61+
62+
for command in commands:
63+
self.assertIsNotNone(
64+
self.commands.pop(
65+
self.commands.index(command.format(**self.args))
66+
))
6567

6668
@patched
6769
def test_symlink_non_english(self):
@@ -80,10 +82,12 @@ def test_symlink_non_english(self):
8082
'ln -nsf {project}/rtd-builds {project}/translations/de',
8183
'ln -nsf {translation}/rtd-builds {project}/translations/en',
8284
]
83-
for (i, command) in enumerate(commands):
84-
self.assertEqual(self.commands[i], command.format(**self.args),
85-
msg=('Command {0} mismatch, expecting {1}'
86-
.format(i, self.commands[i])))
85+
86+
for command in commands:
87+
self.assertIsNotNone(
88+
self.commands.pop(
89+
self.commands.index(command.format(**self.args))
90+
))
8791

8892
@patched
8993
def test_symlink_no_english(self):
@@ -107,7 +111,9 @@ def test_symlink_no_english(self):
107111
'ln -nsf {project}/rtd-builds {project}/translations/de',
108112
'ln -nsf {project}/rtd-builds {project}/translations/en',
109113
]
110-
for (i, command) in enumerate(commands):
111-
self.assertEqual(self.commands[i], command.format(**self.args),
112-
msg=('Command {0} mismatch, expecting {1}'
113-
.format(i, self.commands[i])))
114+
115+
for command in commands:
116+
self.assertIsNotNone(
117+
self.commands.pop(
118+
self.commands.index(command.format(**self.args))
119+
))

tox.ini

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[tox]
2+
envlist = py27,lint,docs
3+
skipsdist = True
4+
5+
[testenv]
6+
setenv =
7+
PYTHONPATH={toxinidir}/readthedocs:{toxinidir}
8+
DJANGO_SETTINGS_MODULE=settings.test
9+
LANG=C
10+
deps = -r{toxinidir}/requirements/pip.txt
11+
changedir = {toxinidir}/readthedocs
12+
commands =
13+
py.test {posargs}
14+
15+
[testenv:docs]
16+
changedir = {toxinidir}/docs
17+
commands =
18+
sphinx-build -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
19+
20+
[testenv:lint]
21+
deps =
22+
{[testenv]deps}
23+
prospector
24+
pylint-django
25+
commands =
26+
prospector \
27+
--profile-path={toxinidir} \
28+
--profile=prospector \
29+
--die-on-tool-error

0 commit comments

Comments
 (0)