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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_chdir-0.2.2.tar.gz.
File metadata
- Download URL: pytest_chdir-0.2.2.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.14.6 Linux/6.17.0-35-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
961a506edf1dfaf39951193217b79167743c9432817fd34f82674630039c8264
|
|
| MD5 |
9f21b15516049d61bc1c797242b8d08b
|
|
| BLAKE2b-256 |
157929f83b6e81d0ae631e9291213de3a85845b0f716baa2e17832483ab2f97d
|
File details
Details for the file pytest_chdir-0.2.2-py3-none-any.whl.
File metadata
- Download URL: pytest_chdir-0.2.2-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.14.6 Linux/6.17.0-35-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2ed292bab84b0d4b47056439a9eccfff06ff3cebc714e277fecdef6243e1003
|
|
| MD5 |
24ffc5234914ce5b8c195b894d411ec7
|
|
| BLAKE2b-256 |
fd5321d9dd6ffd4fa2136ebb8ba1083ac50be7c7fb95fbf2fec387f32808e90a
|