• Stars
    star
    337
  • Rank 124,554 (Top 3 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created over 6 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Separate test code from test cases in pytest.

pytest-cases

Separate test code from test cases in pytest.

Python versions Pytest versions Build Status Tests Status Coverage Status codecov Flake8 Status

Documentation PyPI Downloads Downloads per week GitHub stars DOI

This is the readme for developers. The documentation for users is available here: https://smarie.github.io/python-pytest-cases/

Want to contribute ?

Contributions are welcome ! Simply fork this project on github, commit your contributions, and create pull requests.

Here is a non-exhaustive list of interesting open topics: https://github.com/smarie/python-pytest-cases/issues

nox setup

This project uses nox to define all lifecycle tasks. In order to be able to run those tasks, you should create python 3.7 environment and install the requirements:

>>> conda create -n noxenv python="3.7"
>>> activate noxenv
(noxenv) >>> pip install -r noxfile-requirements.txt

You should then be able to list all available tasks using:

>>> nox --list
Sessions defined in <path>\noxfile.py:

* tests-2.7 -> Run the test suite, including test reports generation and coverage reports.
* tests-3.5 -> Run the test suite, including test reports generation and coverage reports.
* tests-3.6 -> Run the test suite, including test reports generation and coverage reports.
* tests-3.8 -> Run the test suite, including test reports generation and coverage reports.
* tests-3.7 -> Run the test suite, including test reports generation and coverage reports.
- docs-3.7 -> Generates the doc and serves it on a local http server. Pass '-- build' to build statically instead.
- publish-3.7 -> Deploy the docs+reports on github pages. Note: this rebuilds the docs
- release-3.7 -> Create a release on github corresponding to the latest tag

Running the tests and generating the reports

This project uses pytest so running pytest at the root folder will execute all tests on current environment. However it is a bit cumbersome to manage all requirements by hand ; it is easier to use nox to run pytest on all supported python environments with the correct package requirements:

nox

Tests and coverage reports are automatically generated under ./docs/reports for one of the sessions (tests-3.7).

If you wish to execute tests on a specific environment, use explicit session names, e.g. nox -s tests-3.6.

Editing the documentation

This project uses mkdocs to generate its documentation page. Therefore building a local copy of the doc page may be done using mkdocs build -f docs/mkdocs.yml. However once again things are easier with nox. You can easily build and serve locally a version of the documentation site using:

>>> nox -s docs
nox > Running session docs-3.7
nox > Creating conda env in .nox\docs-3-7 with python=3.7
nox > [docs] Installing requirements with pip: ['mkdocs-material', 'mkdocs', 'pymdown-extensions', 'pygments']
nox > python -m pip install mkdocs-material mkdocs pymdown-extensions pygments
nox > mkdocs serve -f ./docs/mkdocs.yml
INFO    -  Building documentation...
INFO    -  Cleaning site directory
INFO    -  The following pages exist in the docs directory, but are not included in the "nav" configuration:
  - long_description.md
INFO    -  Documentation built in 1.07 seconds
INFO    -  Serving on http://127.0.0.1:8000
INFO    -  Start watching changes
...

While this is running, you can edit the files under ./docs/ and browse the automatically refreshed documentation at the local http://127.0.0.1:8000 page.

Once you are done, simply hit <CTRL+C> to stop the session.

Publishing the documentation (including tests and coverage reports) is done automatically by the continuous integration engine, using the nox -s publish session, this is not needed for local development.

Packaging

This project uses setuptools_scm to synchronise the version number. Therefore the following command should be used for development snapshots as well as official releases: python setup.py sdist bdist_wheel. However this is not generally needed since the continuous integration engine does it automatically for us on git tags. For reference, this is done in the nox -s release session.

Merging pull requests with edits - memo

Ax explained in github ('get commandline instructions'):

git checkout -b <git_name>-<feature_branch> main
git pull https://github.com/<git_name>/python-pytest-cases.git <feature_branch> --no-commit --ff-only

if the second step does not work, do a normal auto-merge (do not use rebase!):

git pull https://github.com/<git_name>/python-pytest-cases.git <feature_branch> --no-commit

Finally review the changes, possibly perform some modifications, and commit.

More Repositories

1

python-makefun

Dynamically create python functions with a proper signature.
Python
112
star
2

python-genbadge

A library to generate badges for typical checks (flake8, pytest, coverage, etc.)
Python
63
star
3

python-pytest-harvest

Store data created during your `pytest` tests execution, and retrieve it at the end of the session, e.g. for applicative benchmarking purposes.
Python
60
star
4

python-pytest-steps

A tiny package to ease the creation of test steps with shared intermediate results/state.
Python
55
star
5

python-pyfields

Define fields in python classes. Easily.
Python
45
star
6

python-autoclass

A python 3 library providing functions and decorators to automatically generate class code, such as constructor body or properties getters/setters along with optional support of validation contracts on the generated setters. Its objective is to reduce the amount of copy/paste code in your classes - and hence to help reducing human mistakes :).
Python
36
star
7

pytest-patterns

A couple of examples showing how pytest and its plugins can be combined to solve real-world needs.
Python
35
star
8

python-yamlable

A thin wrapper of PyYaml to convert Python objects to YAML and back
Python
33
star
9

mkdocs-gallery

Same features as sphinx-gallery (https://sphinx-gallery.github.io/) but on mkdocs (https://www.mkdocs.org/) (no sphinx dependency !).
Python
33
star
10

develop-behind-proxy

Some configuration tricks for developers located behind a corporate proxy.
30
star
11

python-valid8

Yet another validation lib ;). Provides tools for general-purpose variable validation, function inputs/outputs validation as well as class fields validation. All entry points raise consistent ValidationError including all contextual details, with dynamic inheritance of ValueError/TypeError as appropriate.
Python
27
star
12

python-decopatch

python decorators made easy.
Python
23
star
13

python-m5p

An implementation of M5 and model trees in python, compliant with scikit-learn.
Python
19
star
14

env-switcher-gui

A very simple cross-OS and python GUI+CLI to manage environment variables.
Python
14
star
15

PyQt5-minimal

A minimal version of the PyQt5 GPL package, so that you do not end up with a 80Mo-large distribution when freezing your application with cx_Freeze, py2exe or others.
Batchfile
13
star
16

python-getversion

Get the version number of any python module or package, reliably.
Python
13
star
17

python-mini-lambda

Simple lambda functions without `lambda x:` prefix and with string conversion capability.
Python
13
star
18

ALL_OF_THE_ABOVE

20 python libs and more: read me first!
11
star
19

python-doit-api

`pydoit` for humans: an API to create `doit` tasks faster and more reliably.
Python
8
star
20

python-odsclient

A nonofficial client for OpenDataSoft API.
Python
8
star
21

python-fprules

`make`-like file pattern rules for build tools such as `doit`
Python
7
star
22

python-pep-ideas

4
star
23

python-spawny

Tiny utility to launch a script in a separate process, possibly using another python executable/environment. The script may be accessed from the main process through a proxy. This project relies on the default multiprocessing module, therefore the child environment does not require any particular package to be present (not even this package).
Python
4
star
24

python-pytest-pilot

Slice in your test base thanks to powerful markers
Python
3
star
25

python-mixture

Mixin classes for great objects !
Python
2
star
26

python-vtypes

Validating types for python - use `isinstance()` to validate both type and value.
Python
2
star
27

python-parsyfiles

A declarative framework to read complex objects made of several files, supporting pluggable parsers and alternate file formats for the same object type. A typical use case is to read collections of test cases on the file system.
Python
2
star
28

python-azureml-client

A generic - unofficial - python 2 & 3 client stack for azureML web services
Python
1
star