PyXR

c:\python24\lib \ distutils \ tests \ support.py



0001 """Support code for distutils test cases."""
0002 
0003 import shutil
0004 import tempfile
0005 
0006 from distutils import log
0007 
0008 
0009 class LoggingSilencer(object):
0010 
0011     def setUp(self):
0012         super(LoggingSilencer, self).setUp()
0013         self.threshold = log.set_threshold(log.FATAL)
0014 
0015     def tearDown(self):
0016         log.set_threshold(self.threshold)
0017         super(LoggingSilencer, self).tearDown()
0018 
0019 
0020 class TempdirManager(object):
0021     """Mix-in class that handles temporary directories for test cases.
0022 
0023     This is intended to be used with unittest.TestCase.
0024     """
0025 
0026     def setUp(self):
0027         super(TempdirManager, self).setUp()
0028         self.tempdirs = []
0029 
0030     def tearDown(self):
0031         super(TempdirManager, self).tearDown()
0032         while self.tempdirs:
0033             d = self.tempdirs.pop()
0034             shutil.rmtree(d)
0035 
0036     def mkdtemp(self):
0037         """Create a temporary directory that will be cleaned up.
0038 
0039         Returns the path of the directory.
0040         """
0041         d = tempfile.mkdtemp()
0042         self.tempdirs.append(d)
0043         return d
0044 
0045 
0046 class DummyCommand:
0047     """Class to store options for retrieval via set_undefined_options()."""
0048 
0049     def __init__(self, **kwargs):
0050         for kw, val in kwargs.items():
0051             setattr(self, kw, val)
0052 
0053     def ensure_finalized(self):
0054         pass
0055 

Generated by PyXR 0.9.4
SourceForge.net Logo