From b8ab8b6da809f9ceecd715113b2c860235186b02 Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Thu, 17 Jun 2004 20:14:50 +0000 Subject: move support code to a helper module to ease re-use --- Lib/distutils/tests/support.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Lib/distutils/tests/support.py (limited to 'Lib/distutils/tests/support.py') diff --git a/Lib/distutils/tests/support.py b/Lib/distutils/tests/support.py new file mode 100644 index 0000000000..cef985d79a --- /dev/null +++ b/Lib/distutils/tests/support.py @@ -0,0 +1,41 @@ +"""Support code for distutils test cases.""" + +import shutil +import tempfile + + +class TempdirManager(object): + """Mix-in class that handles temporary directories for test cases. + + This is intended to be used with unittest.TestCase. + """ + + def setUp(self): + super(TempdirManager, self).setUp() + self.tempdirs = [] + + def tearDown(self): + super(TempdirManager, self).tearDown() + while self.tempdirs: + d = self.tempdirs.pop() + shutil.rmtree(d) + + def mkdtemp(self): + """Create a temporary directory that will be cleaned up. + + Returns the path of the directory. + """ + d = tempfile.mkdtemp() + self.tempdirs.append(d) + return d + + +class DummyCommand: + """Class to store options for retrieval via set_undefined_options().""" + + def __init__(self, **kwargs): + for kw, val in kwargs.items(): + setattr(self, kw, val) + + def ensure_finalized(self): + pass -- cgit v1.2.1