# otp.TmpDir

### *class* TmpDir(rel_path='', \*, suffix='', clean_up=default, base_dir='')

Bases: [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike), `CleanUpFinalizer`

Class to create a temporary directory.
By default, this directory will be deleted automatically after all references to it are gone.
All files and directories under this one will be deleted too.

Base path where directories are created could be set using the `ONE_TICK_TMP_DIR`.
By default they are created under the `tempfile.gettempdir()` folder.

* **Parameters:**
  * **rel_path** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- relative path to the temporary directory.
    If empty, then the name will be auto-generated.
  * **suffix** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- suffix of the name of the temporary directory.
  * **base_dir** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- relative path of the directory where temporary directory will be created.
  * **clean_up** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) -- 

    Controls whether this temporary directory will be deleted automatically
    after all references to it are gone.

    By default,
    [`otp.config.clean_up_tmp_files`](../config.md#onetick.py.configuration.Config.clean_up_tmp_files) is used.

#### SEE ALSO
The testing framework has a `--keep-generated` flag that controls clean up for all related instances
[onetick-py-test plugin features](../../static/testing/features.md#onetick-py-test-features)
