Go to file
苏芳 0dbdad7278
!1 Add python3-pip and python3-tomli to build-depends.
Merge pull request !1 from 苏芳/openkylin/yangtze
2023-02-02 07:12:04 +00:00
.github/workflows Import Upstream version 1.4.1 2022-11-04 15:41:02 +08:00
debian Add python3-pip and python3-tomli to build-depends. 2023-02-02 14:06:40 +08:00
src/pytest_datadir Import Upstream version 1.4.1 2022-11-04 15:41:02 +08:00
tests Import Upstream version 1.4.1 2022-11-04 15:41:02 +08:00
.flake8 Import Upstream version 1.4.1 2022-11-04 15:41:02 +08:00
.gitignore Import Upstream version 1.4.1 2022-11-04 15:41:02 +08:00
.pre-commit-config.yaml Import Upstream version 1.4.1 2022-11-04 15:41:02 +08:00
AUTHORS Import Upstream version 1.4.1 2022-11-04 15:41:02 +08:00
CHANGELOG.rst Import Upstream version 1.4.1 2022-11-04 15:41:02 +08:00
LICENSE Import Upstream version 1.4.1 2022-11-04 15:41:02 +08:00
README.md Import Upstream version 1.4.1 2022-11-04 15:41:02 +08:00
setup.py Import Upstream version 1.4.1 2022-11-04 15:41:02 +08:00
tox.ini Import Upstream version 1.4.1 2022-11-04 15:41:02 +08:00

README.md

pytest-datadir

pytest plugin for manipulating test data directories and files.

Build Status PyPI CondaForge Python Version Code style: black

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.