toolrack.testing
Unit-test features.
- class toolrack.testing.Dir(path)
A helper for creating files and directories under a base directory.
This is meant to be used for test fixtures.
- join(*paths)
Join the specified path fragments with directory prefix.
- Return type:
Path
- mkdir(path=None)
Create a temporary directory and return the
pathlib.Path.By default, a random name is chosen.
- Parameters:
path (
Optional[str]) – if specified, it’s appended to the base directory and all intermiediate directories are created too. A relative path must be specified. A tuple of strings can be also passed, in which case elements are joined usingos.path.sep().- Return type:
Path
- mkfile(path=None, content='', mode=None)
Create a temporary file and return the
pathlib.Path.By default, a random name is chosen.
- Parameters:
path (
Union[str,Path,None]) – if specified, it’s appended to the base directory and all intermiediate directories are created too. A relative path must be specified. A tuple of strings can be also passed, in which case elements are joined usingos.path.sep().content (str) – the content of the file.
mode (int) – Unix permissions for the file.
- Return type:
Path
- mksymlink(target, path=None)
Create a symbolic link and return the
pathlib.Path.By default, a random name is chosen.
- Parameters:
target (
str|Path) – path of the symlink target.path (
Union[str,Path,None]) – if specified, it’s appended to the base directory and all intermiediate directories are created too. A relative path must be specified. A tuple of strings can be also passed, in which case elements are joined usingos.path.sep().
- Return type:
Path
- toolrack.testing.tempdir(tmpdir)
A temporary directory fixture.