pytest-chdir
A pytest fixture for changing current working directory.
Usage
Change directory to tmpdir
Using chtmpdir provides not only creating temporary directory but also moving there automatically.
def test_move_to_tmpdir(chtmpdir):
assert Path.cwd() == chtmpdir
assert str(chtmpdir).startswith("/tmp")
Define new fixtures to change current working directory
By using define_chdir_fixture, you can create a fixture to move to specified directory.
define_chdir_fixture("chetc", Path("/etc"), __name__)
def test_chetc(chetc):
assert Path.cwd() == Path("/etc")
Integrate with pytest-datadir
If you have installed pytest-datadir, you can use chdatadir and chshared_datadir.
def test_chdatadir(chdatadir):
assert str(Path.cwd().stem) == "test_dir"
def test_chshared_datadir(chshared_datadir):
assert str(Path.cwd().stem) == "data"
See also
License
This software is released under the MIT License, see LICENSE.
Release files for pytest-chdir 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest_chdir-0.2.3.tar.gz | 2.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_chdir-0.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.4 kB
Release files / pytest_chdir-0.2.3.tar.gz
| Download URL | pytest_chdir-0.2.3.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5caf98e54dadc3c7e3d0a629640b731006b856d4ac788e912e670b76c04f3cd0
|
|
BLAKE2b-256 checksum How to use checksums |
348dc7f618afd0a65ed60fff7b6f37f6be39d30d69d111193bc3e2d03563c718
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.14.6 Linux/6.17.0-35-generic
|
Release files / pytest_chdir-0.2.3-py3-none-any.whl
| Download URL | pytest_chdir-0.2.3-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e8250d8ace0121fa6c01f6f73533ab7e140142bd7fabd8809f6ed1e5b4b3dd5b
|
|
BLAKE2b-256 checksum How to use checksums |
b31c425020eca84ba8432655453b6e5939e14c9c030e76a934240c4e856687ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.14.6 Linux/6.17.0-35-generic
|