pytest-cases

Separate test code from test cases in pytest.

https://github.com/smarie/python-pytest-cases

Science Score: 59.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
    1 of 21 committers (4.8%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.9%) to scientific vocabulary

Keywords

case concerns data dataset decorator file parameter parametrize pytest separate test test-case testcase

Keywords from Contributors

unit-testing autopep8 codeformatter formatter gofmt pre-commit-hook yapf jax
Last synced: 6 months ago · JSON representation

Repository

Separate test code from test cases in pytest.

Basic Info
Statistics
  • Stars: 365
  • Watchers: 4
  • Forks: 40
  • Open Issues: 52
  • Releases: 110
Topics
case concerns data dataset decorator file parameter parametrize pytest separate test test-case testcase
Created over 7 years ago · Last pushed 6 months ago
Metadata Files
Readme License Zenodo

README.md

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:

```bash

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 \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:

bash 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:

```bash

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'):

bash 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!):

bash 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.

Owner

  • Name: Sylvain Marié
  • Login: smarie
  • Kind: user
  • Company: Schneider Electric

solve. reuse.

GitHub Events

Total
  • Create event: 6
  • Release event: 2
  • Issues event: 15
  • Watch event: 19
  • Delete event: 7
  • Issue comment event: 22
  • Push event: 7
  • Pull request review event: 11
  • Pull request review comment event: 11
  • Pull request event: 14
Last Year
  • Create event: 6
  • Release event: 2
  • Issues event: 15
  • Watch event: 19
  • Delete event: 7
  • Issue comment event: 22
  • Push event: 7
  • Pull request review event: 11
  • Pull request review comment event: 11
  • Pull request event: 14

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 692
  • Total Committers: 21
  • Avg Commits per committer: 32.952
  • Development Distribution Score (DDS): 0.201
Past Year
  • Commits: 7
  • Committers: 2
  • Avg Commits per committer: 3.5
  • Development Distribution Score (DDS): 0.429
Top Committers
Name Email Commits
Sylvain MARIE s****e@s****m 553
Sylvain Marie s****e@s****m 95
Sagi Shadur s****2@g****m 11
Ryan Addessi (raddessi) r****i@g****m 7
Victor Maryama v****a@t****m 4
Paolo Lammens l****o@g****m 4
Zbigniew Jędrzejewski-Szmek z****k@i****l 2
Michele Riva r****a@i****t 2
Eddie Bergman e****s@g****m 2
Tomasz Kłoczko 3****k 1
Ran Benita r****n@u****m 1
Oliver Bestwalter o****r@b****e 1
Kian-Meng Ang k****g@g****m 1
Karthikeyan Singaravelan t****i@g****m 1
Jay Qi 2****i 1
Janick Gerstenberger j****r@g****m 1
Christopher McGirr 7****r 1
Ching-Hwa Yu c****u@g****m 1
Vyas Ramasubramani v****i@g****m 1
jsmadis j****s@g****m 1
nor3th 7****h 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 115
  • Total pull requests: 81
  • Average time to close issues: 3 months
  • Average time to close pull requests: 2 months
  • Total issue authors: 57
  • Total pull request authors: 16
  • Average comments per issue: 2.85
  • Average comments per pull request: 0.94
  • Merged pull requests: 42
  • Bot issues: 0
  • Bot pull requests: 1
Past Year
  • Issues: 15
  • Pull requests: 16
  • Average time to close issues: 4 days
  • Average time to close pull requests: 4 months
  • Issue authors: 7
  • Pull request authors: 3
  • Average comments per issue: 0.6
  • Average comments per pull request: 0.56
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 1
Top Authors
Issue Authors
  • smarie (42)
  • wonboyn (5)
  • kloczek (4)
  • vyasr (3)
  • Jasha10 (3)
  • lilo-d (2)
  • eddiebergman (2)
  • jgersti (2)
  • michele-riva (2)
  • lawschlosser (2)
  • dybi (1)
  • 2e0byo (1)
  • connesy (1)
  • Gutifarra (1)
  • fabaff (1)
Pull Request Authors
  • smarie (60)
  • michele-riva (4)
  • eddiebergman (2)
  • last-partizan (2)
  • bluetech (2)
  • dependabot[bot] (2)
  • saroad2 (2)
  • shaunc (1)
  • kianmeng (1)
  • vyasr (1)
  • nor3th (1)
  • larsoner (1)
  • jayqi (1)
  • chrsmcgrr (1)
  • jammer87 (1)
Top Labels
Issue Labels
new_feature (7) has_workaround (5) enhancement (5) packaging (rpm/apt/...) (3) bug (3) topic: compatibility (3) question (2) wontfix (2) needs_reproducible_example (1) pytest-goodies (1) seems out of scope (1) performance (1) awaiting_bugfix_on_external_dependency (1)
Pull Request Labels
awaiting_bugfix_on_external_dependency (2)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 2,239,870 last-month
  • Total docker downloads: 134,474
  • Total dependent packages: 61
    (may contain duplicates)
  • Total dependent repositories: 234
    (may contain duplicates)
  • Total versions: 156
  • Total maintainers: 1
pypi.org: pytest-cases

Separate test code from test cases in pytest.

  • Versions: 122
  • Dependent Packages: 61
  • Dependent Repositories: 227
  • Downloads: 2,239,870 Last month
  • Docker Downloads: 134,474
Rankings
Dependent packages count: 0.3%
Downloads: 0.7%
Dependent repos count: 1.0%
Docker downloads count: 1.0%
Average: 2.2%
Stargazers count: 3.6%
Forks count: 6.7%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: pytest-cases

Did you ever think that most of your test functions were actually the same test code, but with different data inputs and expected results/exceptions ? `pytest-cases` leverages `pytest` and its great `@pytest.mark.parametrize` decorator, so that you can separate your test cases from your test functions. In addition, `pytest-cases` provides several useful goodies to empower `pytest`. In particular it improves the fixture mechanism to support "fixture unions". This is a major change in the internal `pytest` engine, unlocking many possibilities such as using fixture references as parameter values in a test function.

  • Versions: 34
  • Dependent Packages: 0
  • Dependent Repositories: 7
Rankings
Dependent repos count: 12.9%
Stargazers count: 23.0%
Average: 29.9%
Forks count: 31.9%
Dependent packages count: 51.6%
Last synced: 6 months ago

Dependencies

ci_tools/flake8-requirements.txt pypi
  • bandit <1.7.3
  • flake8 >=3.6,<4
  • flake8-bandit >=2.1.1,<3
  • flake8-bugbear >=20.1.0,<21.0.0
  • flake8-copyright ==0.2.2
  • flake8-docstrings >=1.5,<2
  • flake8-html >=0.4,<1
  • flake8-print >=3.1.1,<4
  • flake8-tidy-imports >=4.2.1,<5
  • genbadge *
  • mccabe >=0.6.1,<1
  • naming >=0.5.1,<1
  • pycodestyle >=2.6.0,<3
  • pydocstyle >=5.1.1,<6
  • pyflakes >=2.2,<3
  • setuptools_scm >=3,<4
noxfile-requirements.txt pypi
  • keyring *
  • makefun *
  • nox *
  • setuptools_scm *
  • toml *
.github/workflows/base.yml actions
  • actions/checkout v2 composite
  • actions/download-artifact master composite
  • actions/setup-python v1 composite
  • actions/upload-artifact master composite
  • codecov/codecov-action v1 composite
  • conda-incubator/setup-miniconda v2 composite
  • kolpav/purge-artifacts-action v1 composite
  • pypa/gh-action-pypi-publish release/v1 composite
pyproject.toml pypi
setup.py pypi