Skip to main content

Expand command-line shortcuts listed in pytest configuration

Project description

pytest-shortcuts

Expand command-line shortcuts listed in pytest configuration

This pytest plugin was generated with Cookiecutter along with @hackebrot's cookiecutter-pytest-plugin template.

Getting Started

Install using your favourite python package manager:

$ pip install pytest-shortcuts

Add some shortcuts to your pytest configuration:

[pytest]
shortcuts =
    --live: -m "live and not slow"
    --slow: -m "live and slow"
    --offline: --disable-socket -m "not live"

Now when you run your tests with eg --live, it will be as if you provided -m "live and not slow".

Bonus: including dotenv files

For each shortcut, you can also define a dotenv file to load with custom configuration:

[pytest]
shortcuts =
    --live: -m "live and not slow" --envfile=.live.env
    --slow: -m "live and slow"

Note that this dotenv file loads the environment very early, but any pytest-plugins will have already been imported by then. Any plugin that relies on an environment variable during module import (and not eg at runtime) may not see values loaded from this file.

Contributing

If you would like to contribute, you may need to install the following development tools:

# Useful for installing tools like tox and pre-commit in a separate environment
pip install --user pipx

# We run the test suite with tox
pipx install tox
pipx install flake8

# Install pre-commit hooks to prevent commits that do not pass static checks
pipx install pre-commit
pre-commit install

Additionally, you will want to install a number of different Python versions for tox to use. I would recommend using pyenv to do this. After you have installed pyenv, run tox to see which Python versions you are missing and enable them. For example:

brew install pyenv              # If you have homebrew
tox -l                          # Check which Python versions are currently required
pipx inject tox tox-pyenv       # Make pyenv versions available to tox
pyenv install 3.6.11            # If you need a Python 3.6
pyenv install 3.7.8             # If you need a Python 3.7
pyenv install 3.8.5             # If you need a Python 3.8
pyenv local 3.6.11 3.7.8 3.8.5  # Make these versions locally available
tox                             # Run the test suite via tox (same as "make test")

A simple Makefile is included to run development commands, just type make to see a list of available commands.

License

Distributed under the terms of the BSD-3 license, "pytest-shortcuts" is free and open source software

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-shortcuts-0.3.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_shortcuts-0.3.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file pytest-shortcuts-0.3.0.tar.gz.

File metadata

  • Download URL: pytest-shortcuts-0.3.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for pytest-shortcuts-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e8b051e8918ea09b6d3c1b9c6a4b562b3ee66923ed99d5ce607074e25bb55efa
MD5 43677b6bec04b3c0b9c7e2fd62485ad1
BLAKE2b-256 b8a90c0b5dba6f7ca8a5c89864cd3072de5a486845bde463d93750a30e80b69d

See more details on using hashes here.

File details

Details for the file pytest_shortcuts-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_shortcuts-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for pytest_shortcuts-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 45444f37e0ee59c68ce1861809cc525c766d3216d89e34959079d05c3335b8c6
MD5 2939c2964892fdc31c22d297c494be5d
BLAKE2b-256 9cc2b439813e112a66da70e9f0a43f3ff17aa953158e19cf34dd670bf0013ceb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page