Skip to main content

Manager for test data: downloads, artifact caching, and a tmpdir context.

Project description

Python package Supported Python Versions GitHub repository Download stats PYPI download rate
License terms GitHub Actions Codecov.io test coverage Codacy.io grade Issues reported
Logo credit Jørgen Stamp, published under a Creative Commons Attribution 2.5 Denmark License.

The datadir-mgr plugin for pytest provides the datadir_mgr fixture which allow test functions to easily download data files and cache generated data files in data directories in a manner that allows for overlaying of results. datadir-mgr is pathlib-based, so complete paths to data files are handled, not just filenames.

This plugin behaves like a limited dictionary, with datadir_mgr[item] returning a path with the most specific scope (out of global, module, [class], [function] that matches the string or path specified by item. In addition to serving data files already stored in the data directory, the fixture provides five methods useful for adding to the test data stored in the repository:

  • The download method allows downloading data files into data directories, with option MD5 checksum checks, un-gzipping, and a progressbar.

  • The savepath fixture lets an arbitrary path relative to the current working directory to be saved at a particular scope in the data directories.

  • The add_scope method lets one add directories from scopes different from the present request to be added to the search path. This lets the results of previous cached steps to be used in scopes other than global.

  • The in_tmp_dir method creates a context in a temporary directory with a list of request file paths copied in. Optionally, all output file paths can be saved at a particular scope at cleanup with an optional exclusion filter pattern (e.g., for excluding log files). Note that files in directories that begin with test_ or end with _test could be confused with scope directories and cannnot be saved. If progressbar is set to “True”, then the progress of file copying will be shown, which is helpful in some long-running pytest jobs, e.g. on Travis.

  • The paths_from_scope returns a list of all paths to files from a specified scope.

Prerequisites

Python 3.6 or greater is required. This package is tested under Linux, MacOS, and Windows using Python 3.9.

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-mgr-1.3.1.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

pytest_datadir_mgr-1.3.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file pytest-datadir-mgr-1.3.1.tar.gz.

File metadata

  • Download URL: pytest-datadir-mgr-1.3.1.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.2 Linux/5.15.15-gentoo-dist

File hashes

Hashes for pytest-datadir-mgr-1.3.1.tar.gz
Algorithm Hash digest
SHA256 59457a8cbc1245630517066f416b64d988ee92c5c400aef9987ffe12fe5ce0e0
MD5 c78f717be72ec4d2c9105e2c5dceb681
BLAKE2b-256 fb52869362b5147601af25dcd1484547dc9130a19ebf67b00d9efac52f41ece0

See more details on using hashes here.

File details

Details for the file pytest_datadir_mgr-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: pytest_datadir_mgr-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.2 Linux/5.15.15-gentoo-dist

File hashes

Hashes for pytest_datadir_mgr-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 216ed01fc9b12ff734fd1a44e40fd890024db79a2b61dfd68eba3194507ba298
MD5 fa859af7be524c2dd3375aa1a6cd14a8
BLAKE2b-256 957446623092520516ab80e43850fc77b665c8c7978cdf7fdf4ff194859493e5

See more details on using hashes here.

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