Skip to main content

pytest-pt: pytest plugin to use *.pt files as tests

This pytest plugin will collect *.pt files as test modules. It uses a custom module loader that always uses importlib (like specifying importmode=importlib to the standard pytest loader) and generates a module name ending in ~pt to prevent namespace collisions.

Installation and Activiation

Normally just install this with Pip or similar: pip install pytest-pt. However, you may also simply deposit the single file src/pytest_pt.py in any directory where it will be found as the code for a (top-level) module.

As long as the plugin package is installed in the current environment it's automatically enabled via the entry points system. The autoload can be disabled using the standard methods, typically the -p no:pytest_pt option on the command line or in a configuration file as shown below. Using -p pytest_pt in a similar way re-enable it if something earlier disabled it.

    #   pyproject.toml
    [tool.pytest.ini_options]
    addopts   = ['-p pytest_pt']

    #   pytest.ini
    [pytest]
    addopts = -p pytest_pt

    #   In a conftest.py in one or more dirs under which you
    #   want to collect *.pt files.
    from pytest_pt import *

For further information on pytest configuration, see the Configuration section of the pytest documentation.

Versions Supported

This supports only pytest 5, 7 and 8; pytest 6 doesn't seem worth supporting because we have no legacy users of it. (This could be added if there is any demand for it.)

  • Python 3.6 probably works, but is not tested due to tox being unhappy about using it.
  • pytest 5 is supported on versions of Python up to 3.9, but not on 3.10 and above.
  • pytest 7 and 8 are tested on Pythons up to 3.12, and will probably work on newer versions of Python when they are released.

Testing

The top-level ./Test script runs tests for all supported versions of Python and pytest. You do not need tox installed (or even pip or virtualenv); the script will take care of bootstrapping those into a local virtualenv using pactivate.

The script installs and uses pythonz to supply the various versions of Python this is tested with. You should run it the first time with -B as the first option to ./Test to install/update pythonz and build the versions of Python that tox will need to run the tests. (The tests are for each minor release from 3.7 to 3.12; pythonz will be asked to build the latest patch release for each of those.)

The test script could be updated to use Pythons from other sources, if there is any call for it.

Tox Arguments

Any command line arguments given to ./Test (with the exception of an initial -B—see above) will be passed on to tox. So, e.g., ./Test -h will make tox print its help message. Typical arguments you might want to pass through ./Test to tox include: use include:

  • run -h: Print help for the tox run command.

  • -a: Print a list of all environments in the default list to be tested. This can be useful for finding an envirionment name for use in the run command below.

  • run -e py3.11-pytest8: Run just a specific tox environment (or multiple ones separated by commas) rather than all environment.

  • config: Print the tox configuration.

Release Process

See cynic-net/pypi-release on GitHub.

Further Documentation

This documentation should be expanded to explain more about the purpose of this, how it works, and how the tests (run with ./Test) work. Contact the author if you're needing further documentation or help: Curt J. Sampson cjs@cynic.net.

Release files for pytest-pt 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-pt 1.2.0
File Size Uploaded
pytest_pt-1.2.0.tar.gz 7.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-pt 1.2.0
File Interpreter ABI Platform
pytest_pt-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.5 kB

Release files / pytest_pt-1.2.0.tar.gz

Download URL pytest_pt-1.2.0.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
08e0b4c440752834a3b1f64e83a8894a1e33a2c8541e802b3d990b65cc794d4f
BLAKE2b-256 checksum
How to use checksums
46531158cc589ff3181e081ce5838f59951a9147711d7f7664dd72bb06f71e17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.2

Release files / pytest_pt-1.2.0-py3-none-any.whl

Download URL pytest_pt-1.2.0-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a68c1db532d9d2d1156c84c2b6c37e06eebfeee9da89c884de93643109fcc025
BLAKE2b-256 checksum
How to use checksums
eabb6efc45b67963031685d6978572da4aa7a42e7d5823c8df1f19dd77a16bbf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.2

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page