Debian Codegraph @

tests/utils.py

raw
1 # -*- coding: utf-8 -*-
2 """Utility functions for CLI Helpers' tests."""
3
4 from __future__ import unicode_literals
5 from functools import wraps
6
7 from .compat import TemporaryDirectory
8
9
10 def with_temp_dir(f):
11 """A wrapper that creates and deletes a temporary directory."""
12
13 @wraps(f)
14 def wrapped(*args, **kwargs):
15 with TemporaryDirectory() as temp_dir:
16 return f(*args, temp_dir=temp_dir, **kwargs)
17
18 return wrapped