File: utils.py

package info (click to toggle)
cli-helpers 2.7.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 356 kB
  • sloc: python: 2,208; makefile: 16
file content (18 lines) | stat: -rw-r--r-- 446 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# -*- coding: utf-8 -*-
"""Utility functions for CLI Helpers' tests."""

from __future__ import unicode_literals
from functools import wraps

from .compat import TemporaryDirectory


def with_temp_dir(f):
    """A wrapper that creates and deletes a temporary directory."""

    @wraps(f)
    def wrapped(*args, **kwargs):
        with TemporaryDirectory() as temp_dir:
            return f(*args, temp_dir=temp_dir, **kwargs)

    return wrapped