Skip to content

Commit da6b5b4

Browse files
committed
Documentation update
- add automatic documentation build - minor documentation cleanup, change theme to nature
1 parent 489d26c commit da6b5b4

File tree

5 files changed

+128
-30
lines changed

5 files changed

+128
-30
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ python:
77
- "3.7"
88
- "3.8"
99
- "pypy"
10+
env:
11+
global:
12+
secure: T6vjQsfhlpCwD0dsVZxDbUD5rvqiOz27ex3nwGvVFWnu0ospPbqzw1MqZcjyFvwcLWF+TrJbVf7UxxTM4JHESZTwcSQ1zXhzZ/pRhCKRa7q7fbVkMptEuarUVmnZZAs9GqZecetCA+ka5dSlHEJdIZwyHRmGV8hOx2w/OHRLEJTpSxT7NTkoKTATPxEzseAup1cJ47PGpnLQYXc0H2DgedgUqboU35Rkbya38gptKqFJJ8K3VuCr+j91Pq/rTntMIND3OsBkzPF1PE08tC15G9bBwRi+nER0BZSfxKkmoTLh7yDJhyyzuTDedaZInCziRYCbhQfsCn8QRCyiVeRiCVt1+/2yNt5lJYZwxpQGyYMOA//zlEDu7Z1uYSnkvy4BkI5g22IrjHLcij1lAaJ3lkafINbcUqlwv4sp/xgT8VXCfiDUadvzm+O9rBo6GlVrgWvdV0ExkSWYDu77ruGHZT3XCZ5ZpTf8OtwX71yHs1o5A5lzfPf1DA+fKPiWsu8jOYlStPn5v81ppqYzIz3JiaWgypCDWB7TLWT6iFjfK5hRWNJQn7aVKx5m86Dtu2cxDdBUDhK8fhbIWAQsdyLMcsXEGK1nekxEK8oM28g0hvifQqS1Up+MXmG6xQg8inbvWuZhwE6cnjDyb5CnaI+KAVxtrhVNlYkv8405fe6XumE=
1013
install:
1114
- pip install tox
1215
- pip install python-coveralls
@@ -15,4 +18,6 @@ script:
1518
- tox -e $(tox -l | grep $TOX_PYTHON_VERSION | paste -sd "," -)
1619
after_success:
1720
- coveralls
21+
- pip install sphinx
22+
- ./build-docs.sh
1823
sudo: false

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
## Unreleased
44

55
### Fixes
6-
- fixes the handling of unknown marker attributes (test had been skipped)
6+
- fixed the handling of unknown marker attributes (test had been skipped)
7+
8+
### Infrastructure
9+
- added automatic documentation build on change
710

811
## [Version 0.7.1](https://pypi.org/project/pytest-order/0.7.1/)
912
Update after renaming the repository and the package.

build-docs.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
# Create html documentation from docs sources using sphinx
3+
# and check it into gh-pages branch using the same commit message.
4+
# Skipped if not the master branch, triggered by a pull request,
5+
# nothing has been changed in docs/, # or the string SKIP-AUTODOC
6+
# appears in the commit message.
7+
8+
# only process after the last matrix build
9+
if [ "$TRAVIS_PYTHON_VERSION" != "pypy" ]; then
10+
echo "Not on last matrix build, skipping"
11+
exit 0
12+
fi
13+
14+
SOURCE_BRANCH="master"
15+
TARGET_BRANCH="gh-pages"
16+
REPO_URL="https://${GH_TOKEN}@github.com/mrbean-bremen/pytest-order.git"
17+
18+
if [ "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
19+
echo "Not on $SOURCE_BRANCH branch, skipping"
20+
exit 0
21+
fi
22+
23+
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
24+
echo "This is a pull request, skipping"
25+
exit 0
26+
fi
27+
28+
# enable error reporting to the console
29+
set -e
30+
31+
# save last commit log - will be used for the doc commit
32+
LAST_COMMIT=`git log -1 --pretty=%B`
33+
34+
# all documentaion changes happen in 'docs', as we have no source code
35+
# documentation - only consider changes in that path
36+
LAST_DOC_COMMIT=`git log -1 --pretty=%B docs`
37+
if [ "$LAST_COMMIT" != "$LAST_DOC_COMMIT" ]; then
38+
echo "No changes in documentation, skipping"
39+
exit 0
40+
fi
41+
42+
if [[ $LAST_COMMIT == *"SKIP-AUTODOC"* ]]; then
43+
echo "Autodoc switched off in commit message, skipping"
44+
exit 0
45+
fi
46+
47+
# create the docs using sphinx
48+
cd docs
49+
make html
50+
cd ..
51+
52+
# clone `gh-pages' branch of the repository using encrypted GH_TOKEN for authentification
53+
git clone $REPO_URL -b $TARGET_BRANCH ../pytest_order_gh-pages
54+
55+
# copy generated HTML files to dev part of `gh-pages' branch
56+
cp -r docs/build/html/* ../pytest_order_gh-pages/dev
57+
58+
# commit and push generated content to `gh-pages' branch
59+
cd ../pytest_order_gh-pages
60+
git config user.name "Travis CI"
61+
git config user.email "[email protected]"
62+
git commit -a -m "$LAST_COMMIT"
63+
git push --quiet $REPO_URL $TARGET_BRANCH > /dev/null 2>&1

docs/source/conf.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@
1212
# All configuration values have a default; values that are commented out
1313
# serve to show the default.
1414

15-
import os
16-
17-
__here__ = os.path.abspath(os.path.dirname(__file__))
18-
1915
# If extensions (or modules to document with autodoc) are in another directory,
2016
# add these directories to sys.path here. If the directory is relative to the
2117
# documentation root, use os.path.abspath to make it absolute, like shown here.
22-
#sys.path.insert(0, os.path.abspath('.'))
18+
import os
19+
import sys
20+
21+
sys.path.insert(
22+
0, os.path.split(os.path.split(os.path.dirname(os.path.abspath(
23+
__file__)))[0])[0])
24+
25+
from pytest_order import __version__
2326

2427
# -- General configuration ------------------------------------------------
2528

@@ -57,8 +60,7 @@
5760
# |version| and |release|, also used in various other places throughout the
5861
# built documents.
5962
#
60-
exec(open(os.path.join(__here__, '..', '..', 'pytest_order',
61-
'_version.py')).read())
63+
6264
# The short X.Y version.
6365
version = __version__
6466
# The full version, including alpha/beta/rc tags.
@@ -107,7 +109,7 @@
107109

108110
# The theme to use for HTML and HTML Help pages. See the documentation for
109111
# a list of builtin themes.
110-
html_theme = 'default'
112+
html_theme = 'nature'
111113

112114
# Theme options are theme-specific and customize the look and feel of a theme
113115
# further. For a list of options available for each theme, see the
@@ -136,7 +138,7 @@
136138
# Add any paths that contain custom static files (such as style sheets) here,
137139
# relative to this directory. They are copied after the builtin static files,
138140
# so a file named "default.css" will overwrite the builtin "default.css".
139-
html_static_path = ['_static']
141+
html_static_path = []
140142

141143
# Add any extra paths that contain custom files (such as robots.txt or
142144
# .htaccess) here, relative to this directory. These files are copied

docs/source/index.rst

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
pytest-order: run your tests in order
2-
======================================
3-
pytest-order is a pytest plugin to run your tests in any order that
4-
you specify. It provides the marker ``order``, that defines when your tests
5-
should run in relation to each other. They can be absolute (i.e. first, or
6-
second-to-last) or relative (i.e. run this test before this other test).
1+
Introduction
2+
============
3+
``pytest-order`` is a pytest plugin which allows you to customize the order
4+
in which run your tests are run. It provides the marker ``order``, that has
5+
attributes that defines when your tests should run in relation to each other.
6+
These attributes can be absolute (i.e. first, or second-to-last) or relative
7+
(i.e. run this test before this other test).
78

89
Relationship with pytest-ordering
910
---------------------------------
@@ -46,8 +47,8 @@ The latest master can be installed from the GitHub sources:
4647
4748
pip install git+https://github.com/mrbean-bremen/pytest-order
4849
49-
Quickstart
50-
----------
50+
Overview
51+
--------
5152
Ordinarily pytest will run tests in the order that they appear in a module.
5253
For example, for the following tests:
5354

@@ -100,11 +101,13 @@ With pytest-order, you can change the default ordering as follows:
100101

101102
=========================== 2 passed in 0.01 seconds ===========================
102103

103-
This is a trivial example, but ordering is respected across test files.
104-
There are several possibilities to define the order.
104+
Usage
105+
=====
106+
The above is a trivial example, but ordering is respected across test files.
107+
There are currently three possibilities to define the order:
105108

106-
By number
107-
---------
109+
Order by number
110+
---------------
108111
As already shown above, the order can be defined using ordinal numbers.
109112
Negative numbers are also allowed - they are used the same way as indexes
110113
are used in Python lists, e.g. to count from the end:
@@ -144,13 +147,14 @@ are used in Python lists, e.g. to count from the end:
144147

145148
=========================== 4 passed in 0.02 seconds ===========================
146149

150+
There is no limit for the numbers that can be used in this way.
147151

148-
Ordinals
149-
--------
152+
Order using ordinals
153+
--------------------
150154

151155
You can also use markers such as "first", "second", "last", and
152156
"second_to_last". These are convenience notations, and have the same effect
153-
as the numbers 1, 2, -1 and -2 that have been shown above:
157+
as the numbers 0, 1, -1 and -2 that have been shown above:
154158

155159
.. code:: python
156160
@@ -187,9 +191,28 @@ as the numbers 1, 2, -1 and -2 that have been shown above:
187191

188192
=========================== 4 passed in 0.02 seconds ===========================
189193

190-
Relative to other tests
191-
-----------------------
192-
194+
Convenience names are only defined for the first and the last 8 numbers,
195+
here is the complete list with the corresponding numbers:
196+
197+
- 'first': 0
198+
- 'second': 1
199+
- 'third': 2
200+
- 'fourth': 3
201+
- 'fifth': 4
202+
- 'sixth': 5
203+
- 'seventh': 6
204+
- 'eighth': 7
205+
- 'last': -1
206+
- 'second_to_last': -2
207+
- 'third_to_last': -3
208+
- 'fourth_to_last': -4
209+
- 'fifth_to_last': -5
210+
- 'sixth_to_last': -6
211+
- 'seventh_to_last': -7
212+
- 'eighth_to_last': -8
213+
214+
Order relative to other tests
215+
-----------------------------
193216
The test order can be defined relative to other tests, which are referenced
194217
by their name:
195218

@@ -222,9 +245,12 @@ by their name:
222245

223246
=========================== 4 passed in 0.02 seconds ===========================
224247

248+
Configuration
249+
=============
250+
Currently there is only one option that changes the behavior of the plugin.
251+
225252
``--indulgent-ordering`` and overriding ordering
226253
------------------------------------------------
227-
228254
You may sometimes find that you want to suggest an ordering of tests, while
229255
allowing it to be overridden for good reason. For example, if you run your test
230256
suite in parallel and have a number of tests which are particularly slow, it
@@ -239,7 +265,6 @@ pytest-order *before* the sort from ``--failed-first``, allowing the failed
239265
tests to be sorted to the front.
240266

241267

242-
243268
.. toctree::
244269
:maxdepth: 2
245270

0 commit comments

Comments
 (0)