File: common.py

package info (click to toggle)
ufo-core 0.17.0.22.gc831aec-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,184 kB
  • sloc: ansic: 10,768; python: 1,004; lisp: 266; cpp: 98; xml: 55; makefile: 25; sh: 25
file content (29 lines) | stat: -rw-r--r-- 450 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
import tempfile
import shutil
import contextlib


def disable(func):
    def empty():
        pass

    return empty


class TestDir(object):
    def __init__(self, path):
        self.root = path

    def path(self, name):
        return os.path.join(self.root, name)

    def __str__(self):
        return self.root


@contextlib.contextmanager
def tempdir():
    root = tempfile.mkdtemp()
    yield TestDir(root)
    shutil.rmtree(root)