Skip to main content

pytest plugin to provide data from files loaded automatically

Project description


[Github Actions: Test status]

A pytest plugin to provide fixtures to load test data from files automatically.



This plugin provides following fixtures for each test modules.


test_data_info provides a namedtuple object, data_from_files.ModuleInfo, has the following values for each test modules.

  • root: test root dir, <package_dir>/tests/ by default and is configurable with –test-root (test_root) option.

  • datadir: test data dir using the fixture will be searched under <root>/<test_data_dirname>/, where test_data_dirname is configurable with –test-data-dirname option.

    • if the test code using the fixture is tests/, then datadir becomes tests/data/foo/

    • if the test code using the fixture is tests/foo/bar/, then datadir becomes tests/data/foo/bar/baz

  • subdirs: names of sub dirs relative to datadir if such dirs exist.


test_data provides a list of or a list of lists of namedtuple objects, data_from_files.DataInfo, has the following values.

  • data: data loaded from a file <path> under <datadir>

  • path: a file path contains the data

  • datadir: dir contains the test data file


  • –test-root: test root dir where test data are seached [<package_dir>/tests]

  • –test-data-dirname: test data dir name [data]

  • –test-data-pattern: test data file path pattern relative to datadir [**/*.*]


  • tests/ and test data under tests/data/plugin/

  • tests/ and test data under tests/data/plugin_no_data

  • tests/foo/ and test data under tests/data/foo/bar



  • pytest obviously

  • PyYAML [1] is optionally required to load data from YAML files

  • anyconfig [2] is optionally required to load data in formats anyconfig and/or its plugins support.

How to install

  • PyPI:

    pip install pytest_data_from_files
  • From git repo:

    pip install git+
  • Build wheel and install it:

    tox -e dists && pip install dist/pytest_data_from_files-*.whl

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-data-from-files-0.2.0.tar.gz (15.8 kB view hashes)

Uploaded Source

Built Distribution

pytest_data_from_files-0.2.0-py2.py3-none-any.whl (8.9 kB view hashes)

Uploaded Python 2 Python 3

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