diff options
| author | Tarek Ziadé <ziade.tarek@gmail.com> | 2009-09-21 12:19:07 (GMT) |
|---|---|---|
| committer | Tarek Ziadé <ziade.tarek@gmail.com> | 2009-09-21 12:19:07 (GMT) |
| commit | 6d2db3784aff7f85aa4b814e7312e599b124498e (patch) | |
| tree | b122a9f20ca1ac4e6bd4d9da4f9d825678b1d1d7 /Lib/distutils/tests/test_cmd.py | |
| parent | 1d18b5b92919493526ed021d83479777f0bb6700 (diff) | |
| download | cpython-6d2db3784aff7f85aa4b814e7312e599b124498e.zip cpython-6d2db3784aff7f85aa4b814e7312e599b124498e.tar.gz cpython-6d2db3784aff7f85aa4b814e7312e599b124498e.tar.bz2 | |
improved distutils test coverage: now the DEBUG mode is covered too (will help fix the issue #6954 in py3k branch)
Diffstat (limited to 'Lib/distutils/tests/test_cmd.py')
| -rw-r--r-- | Lib/distutils/tests/test_cmd.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/distutils/tests/test_cmd.py b/Lib/distutils/tests/test_cmd.py index d6438b5..2174efb 100644 --- a/Lib/distutils/tests/test_cmd.py +++ b/Lib/distutils/tests/test_cmd.py @@ -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) |
