mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
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:
parent
1d18b5b929
commit
6d2db3784a
5 changed files with 93 additions and 2 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue