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 12:19:07 +00:00
parent 1d18b5b929
commit 6d2db3784a
5 changed files with 93 additions and 2 deletions

View file

@ -1,10 +1,12 @@
"""Tests for distutils.cmd."""
import unittest
import os
from test.test_support import captured_stdout
from distutils.cmd import Command
from distutils.dist import Distribution
from distutils.errors import DistutilsOptionError
from distutils import debug
class MyCmd(Command):
def initialize_options(self):
@ -102,6 +104,22 @@ class CommandTestCase(unittest.TestCase):
cmd.option2 = 'xxx'
self.assertRaises(DistutilsOptionError, cmd.ensure_dirname, 'option2')
def test_debug_print(self):
cmd = self.cmd
with captured_stdout() as stdout:
cmd.debug_print('xxx')
stdout.seek(0)
self.assertEquals(stdout.read(), '')
debug.DEBUG = True
try:
with captured_stdout() as stdout:
cmd.debug_print('xxx')
stdout.seek(0)
self.assertEquals(stdout.read(), 'xxx\n')
finally:
debug.DEBUG = False
def test_suite():
return unittest.makeSuite(CommandTestCase)