py.test <files> |
Run py.test tool
|
--maxfail=X |
Exit after failing X tests
|
--durations=10 |
Use this to Profile your tests (time taken)
|
--cov=path |
Run
coverage within the project path |
--cov-report term-missing |
Add this to show which lines were not covered
|
pip install pytestpip install pytest-sugarpip install pytest-cov
client = app.test_client() |
Gives you an
Test Client object |
client.get(url) |
Makes a GET request
|
client.post(url, data=[]) |
Makes a POST request
|
client.put(url, data=[]) |
Makes a PUT request
|
.coveragerc |
Default filename looked for
|
[report] |
Section defining the report
|
exclude_lines = |
Exclude lines defined after
|
exclude_lines = the lines as they are in Python code
@pytest.fixture() |
Fixture decorator
|
scope="session" |
Scope for the fixture: Can be
session, module, class or function |
params=[] |
For each value, the fixture will be called with that value (this makes multiple calls)
|
autouse=False |
All tests in the session use the fixture automatically
|
def my_fixture(request) |
Putting
request object in fixture gives you access to the pytest request (e.g. put a finalizer) |
pytest --fixtures |
See all available fixtures
|
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.