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.2.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

pytest_datadir-1.2.0-py2.py3-none-any.whl (4.0 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for pytest-datadir-1.2.0.tar.gz
Algorithm Hash digest
SHA256 aca3b8c6a825acae3c3f60cfc2ed3c57c37505040e1c2ac73d215f10bae74e61
MD5 825694b90c0ff0f918a8a9048fe5ada4
BLAKE2b-256 9c87a2c9f031b6a897064f48ab51d83bd52487130e9b5aed2f1b46d1eb220314

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for pytest_datadir-1.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 95ace0da83531b3757b1ee57674299154b41905d9f528ab79032b2062923908b
MD5 174fa14713689f59b9ab1635322c0b5f
BLAKE2b-256 80c1300fb4f41d94f1944d2ed1b5653ee3e63f4686e4fe71d55437ed5cf8402b

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