Commit b497c76a authored by Jim Fulton's avatar Jim Fulton

Cleaned up some testing support.

parent 63e57632
...@@ -53,6 +53,10 @@ def system(command, input=''): ...@@ -53,6 +53,10 @@ def system(command, input=''):
return o.read() return o.read()
def buildoutSetUp(test): def buildoutSetUp(test):
# we both need to make sure that HOME isn't set and be prepared
# to restore whatever it was after the test.
test.globs['_oldhome'] = os.environ.pop('HOME', None)
sample = tempfile.mkdtemp('sample-buildout') sample = tempfile.mkdtemp('sample-buildout')
for name in ('bin', 'eggs', 'develop-eggs', 'parts'): for name in ('bin', 'eggs', 'develop-eggs', 'parts'):
os.mkdir(os.path.join(sample, name)) os.mkdir(os.path.join(sample, name))
...@@ -92,6 +96,8 @@ def buildoutSetUp(test): ...@@ -92,6 +96,8 @@ def buildoutSetUp(test):
def buildoutTearDown(test): def buildoutTearDown(test):
shutil.rmtree(test.globs['sample_buildout']) shutil.rmtree(test.globs['sample_buildout'])
os.chdir(test.globs['__original_wd__']) os.chdir(test.globs['__original_wd__'])
if test.globs['_oldhome'] is not None:
os.environ['HOME'] = test.globs['_oldhome']
script_template = '''\ script_template = '''\
......
...@@ -71,26 +71,17 @@ def linkerTearDown(test): ...@@ -71,26 +71,17 @@ def linkerTearDown(test):
shutil.rmtree(test.globs['_sample_eggs_container']) shutil.rmtree(test.globs['_sample_eggs_container'])
zc.buildout.testing.buildoutTearDown(test) zc.buildout.testing.buildoutTearDown(test)
def buildoutSetUp(test): def buildoutTearDown(test):
zc.buildout.testing.buildoutSetUp(test)
test.globs['_oldhome'] = os.environ.get('HOME')
def buildoutTearDoen(test):
if test.globs['_oldhome'] is not None:
os.environ['HOME'] = test.globs['_oldhome']
shutil.rmtree(test.globs['extensions']) shutil.rmtree(test.globs['extensions'])
shutil.rmtree(test.globs['home']) shutil.rmtree(test.globs['home'])
zc.buildout.testing.buildoutTearDown(test) zc.buildout.testing.buildoutTearDown(test)
def test_suite(): def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
#doctest.DocTestSuite(),
doctest.DocFileSuite( doctest.DocFileSuite(
'buildout.txt', 'buildout.txt',
setUp=zc.buildout.testing.buildoutSetUp, setUp=zc.buildout.testing.buildoutSetUp,
tearDown=zc.buildout.testing.buildoutTearDown, tearDown=buildoutTearDown,
checker=renormalizing.RENormalizing([ checker=renormalizing.RENormalizing([
(re.compile('__buildout_signature__ = recipes-\S+'), (re.compile('__buildout_signature__ = recipes-\S+'),
'__buildout_signature__ = recipes-SSSSSSSSSSS'), '__buildout_signature__ = recipes-SSSSSSSSSSS'),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment