Skip to main content

pytest plugin for test data directories and files

Project description

pytest-datadir

pytest plugin for manipulating test data directories and files.

Build Status PyPI PythonVersions CondaForge

Usage

pytest-datadir will look up for a directory with the name of your module or the global 'data' folder. Let's say you have a structure like this:

.
├── data/
│   └── hello.txt
├── test_hello/
│   └── spam.txt
└── test_hello.py

You can access the contents of these files using injected variables datadir (for test_ folder) or shared_datadir (for data folder):

def test_read_global(shared_datadir):
    contents = (shared_datadir / 'hello.txt').read_text()
    assert contents == 'Hello World!\n'

def test_read_module(datadir):
    contents = (datadir / 'spam.txt').read_text()
    assert contents == 'eggs\n'

pytest-datadir will copy the original file to a temporary folder, so changing the file contents won't change the original data file.

Both datadir and shared_datadir fixtures are pathlib.Path objects.

Releases

Follow these steps to make a new release:

  1. Create a new branch release-X.Y.Z from master.
  2. Update CHANGELOG.rst.
  3. Open a PR.
  4. After it is green and approved, push a new tag in the format X.Y.Z.

Travis will deploy to PyPI automatically.

Afterwards, update the recipe in conda-forge/pytest-datadir-feedstock.

License

MIT.

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-datadir-1.3.0.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

pytest_datadir-1.3.0-py2.py3-none-any.whl (5.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pytest-datadir-1.3.0.tar.gz.

File metadata

  • Download URL: pytest-datadir-1.3.0.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.3

File hashes

Hashes for pytest-datadir-1.3.0.tar.gz
Algorithm Hash digest
SHA256 275f641dbb045896c7d185cfbe79afd15270eed09d334c2ceb17396e634e22dd
MD5 ed96b9e5ffca7b4923373388ae330c98
BLAKE2b-256 393589eb23f239fceab66b38b9c42ac1ab5f0cedb75aacb6ef4e3ebd1160687a

See more details on using hashes here.

Provenance

File details

Details for the file pytest_datadir-1.3.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pytest_datadir-1.3.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.3

File hashes

Hashes for pytest_datadir-1.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 870511dd6bbfa1aa3b32a2e76bdd7fdb0239fac377b02c694338c6c184dd8c20
MD5 53e79000415e23d209a992d1aa9dd208
BLAKE2b-256 85b872b4d1c3d2ef7e3c2de2156efa9826503b46d89da67a88ef727aade91a27

See more details on using hashes here.

Provenance

Supported by

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