Select tests of a given level or lower
Project description
# pytest-level
Mark test cases with a *level*, then de-select tests with a given level or higher.
When giving a teaching/practice assignment with pre-written tests, either all
tests can be given at once (leaving students overwhelmed and unsure which
failures should be fixed next), or piece-wise (in individual files -- which
becomes a mess for larger projects).
With this plugin, tests for a teaching/practice assignment can be given in
a single file. Students are then told to run with `--level 1`, fix the few red
tests, then go to `--level 2`, etc.
Unlike with keywords, all the lower-level tests will still be run:
`--level 2` will run both `level(1)` and `level(2)` tests.
## Installation
In a Python environment (e.g. `venv`), do:
python -m pip install pytest-level
## Usage
Mark tests with a numeric `level` marker:
@pytest.mark.level(1)
def test_basic_math():
assert 1 + 1 == 2
@pytest.mark.level(2)
def test_intermediate_math():
assert 10 / 2 == 5
@pytest.mark.level(3)
def test_complicated_math():
assert 10 ** 3 == 1000
Then, run pytest with `--level`:
python -m pytest --level 2
This will deselect tests of a higher level.
Without `--level`, all tests are run.
## Licence
The code is available under a MIT license. May it serve you well.
Mark test cases with a *level*, then de-select tests with a given level or higher.
When giving a teaching/practice assignment with pre-written tests, either all
tests can be given at once (leaving students overwhelmed and unsure which
failures should be fixed next), or piece-wise (in individual files -- which
becomes a mess for larger projects).
With this plugin, tests for a teaching/practice assignment can be given in
a single file. Students are then told to run with `--level 1`, fix the few red
tests, then go to `--level 2`, etc.
Unlike with keywords, all the lower-level tests will still be run:
`--level 2` will run both `level(1)` and `level(2)` tests.
## Installation
In a Python environment (e.g. `venv`), do:
python -m pip install pytest-level
## Usage
Mark tests with a numeric `level` marker:
@pytest.mark.level(1)
def test_basic_math():
assert 1 + 1 == 2
@pytest.mark.level(2)
def test_intermediate_math():
assert 10 / 2 == 5
@pytest.mark.level(3)
def test_complicated_math():
assert 10 ** 3 == 1000
Then, run pytest with `--level`:
python -m pytest --level 2
This will deselect tests of a higher level.
Without `--level`, all tests are run.
## Licence
The code is available under a MIT license. May it serve you well.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pytest-level-0.1.tar.gz
(2.1 kB
view details)
Built Distribution
File details
Details for the file pytest-level-0.1.tar.gz
.
File metadata
- Download URL: pytest-level-0.1.tar.gz
- Upload date:
- Size: 2.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c48dc784f1e0e1cb6c0d8fff04311a2a206517e59c5d800e2fcd1267a08568f |
|
MD5 | 9786973bcadbbb823bb7a2905c06f9af |
|
BLAKE2b-256 | f5618750b4ada4d595dfe31b46dd9ee6b60f9ab1dc62c29b80880cab041d94ac |
File details
Details for the file pytest_level-0.1-py3-none-any.whl
.
File metadata
- Download URL: pytest_level-0.1-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d054ab4ac4b2cc140b07be53c76335db66a8734af963fda83d3357f4d210d65 |
|
MD5 | 7568f07afc3747c82e86128a41891097 |
|
BLAKE2b-256 | ae46fdedfd0a46f9afa5bacb4f176f62f6a146a476887a76ece984b78c65643a |