Merged revisions 74988 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r74988 | tarek.ziade | 2009-09-21 14:19:07 +0200 (Mon, 21 Sep 2009) | 1 line

  improved distutils test coverage: now the DEBUG mode is covered too (will help fix the issue #6954 in py3k branch)
........
This commit is contained in:
Tarek Ziadé 2009-09-21 13:01:54 +00:00
parent eb097fca52
commit 03d5d08798
7 changed files with 97 additions and 6 deletions

View file

@ -6,6 +6,7 @@ import os
import shutil
import sys
import test.support
from test.support import captured_stdout
import unittest
@ -33,10 +34,12 @@ class CoreTestCase(unittest.TestCase):
def setUp(self):
self.old_stdout = sys.stdout
self.cleanup_testfn()
self.old_argv = sys.argv[:]
def tearDown(self):
sys.stdout = self.old_stdout
self.cleanup_testfn()
sys.argv = self.old_argv[:]
def cleanup_testfn(self):
path = test.support.TESTFN
@ -73,6 +76,23 @@ class CoreTestCase(unittest.TestCase):
output = output[:-1]
self.assertEqual(cwd, output)
def test_debug_mode(self):
# this covers the code called when DEBUG is set
sys.argv = ['setup.py', '--name']
with captured_stdout() as stdout:
distutils.core.setup(name='bar')
stdout.seek(0)
self.assertEquals(stdout.read(), 'bar\n')
distutils.core.DEBUG = True
try:
with captured_stdout() as stdout:
distutils.core.setup(name='bar')
finally:
distutils.core.DEBUG = False
stdout.seek(0)
wanted = "options (after parsing config files):\n"
self.assertEquals(stdout.readlines()[0], wanted)
def test_suite():
return unittest.makeSuite(CoreTestCase)