diff options
| author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2011-08-18 10:11:00 +0100 |
|---|---|---|
| committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2011-08-18 10:11:00 +0100 |
| commit | 1797898898a76efb0f3e78b394675033f3c2fad2 (patch) | |
| tree | 46b8e37163c2b739fe36bddf2fb211910a1a545c /distutils2/tests/test_command_cmd.py | |
| parent | cd2c1aa7aa06eae25f9b06a1aa75821f5baf3dda (diff) | |
| download | disutils2-1797898898a76efb0f3e78b394675033f3c2fad2.tar.gz | |
Backported packaging from cpython default, overwriting previous version.
Diffstat (limited to 'distutils2/tests/test_command_cmd.py')
| -rw-r--r-- | distutils2/tests/test_command_cmd.py | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/distutils2/tests/test_command_cmd.py b/distutils2/tests/test_command_cmd.py index 1a6faf6..1b0f622 100644 --- a/distutils2/tests/test_command_cmd.py +++ b/distutils2/tests/test_command_cmd.py @@ -1,24 +1,26 @@ """Tests for distutils.cmd.""" import os -from distutils2.tests import run_unittest from distutils2.command.cmd import Command from distutils2.dist import Distribution -from distutils2.errors import DistutilsOptionError -from distutils2.tests import unittest +from distutils2.errors import PackagingOptionError +from distutils2.tests import support, unittest + class MyCmd(Command): def initialize_options(self): pass -class CommandTestCase(unittest.TestCase): + +class CommandTestCase(support.LoggingCatcher, + unittest.TestCase): def setUp(self): + super(CommandTestCase, self).setUp() dist = Distribution() self.cmd = MyCmd(dist) def test_make_file(self): - cmd = self.cmd # making sure it raises when infiles is not a string or a list/tuple @@ -33,12 +35,7 @@ class CommandTestCase(unittest.TestCase): cmd.make_file(infiles='in', outfile='out', func='func', args=()) def test_dump_options(self): - - msgs = [] - def _announce(msg, level): - msgs.append(msg) cmd = self.cmd - cmd.announce = _announce cmd.option1 = 1 cmd.option2 = 1 cmd.user_options = [('option1', '', ''), ('option2', '', '')] @@ -46,6 +43,7 @@ class CommandTestCase(unittest.TestCase): wanted = ["command options for 'MyCmd':", ' option1 = 1', ' option2 = 1'] + msgs = self.get_logs() self.assertEqual(msgs, wanted) def test_ensure_string(self): @@ -58,7 +56,7 @@ class CommandTestCase(unittest.TestCase): self.assertTrue(hasattr(cmd, 'option2')) cmd.option3 = 1 - self.assertRaises(DistutilsOptionError, cmd.ensure_string, 'option3') + self.assertRaises(PackagingOptionError, cmd.ensure_string, 'option3') def test_ensure_string_list(self): cmd = self.cmd @@ -75,10 +73,10 @@ class CommandTestCase(unittest.TestCase): cmd.not_string_list = ['one', 2, 'three'] cmd.not_string_list2 = object() - self.assertRaises(DistutilsOptionError, + self.assertRaises(PackagingOptionError, cmd.ensure_string_list, 'not_string_list') - self.assertRaises(DistutilsOptionError, + self.assertRaises(PackagingOptionError, cmd.ensure_string_list, 'not_string_list2') def test_ensure_filename(self): @@ -86,17 +84,18 @@ class CommandTestCase(unittest.TestCase): cmd.option1 = __file__ cmd.ensure_filename('option1') cmd.option2 = 'xxx' - self.assertRaises(DistutilsOptionError, cmd.ensure_filename, 'option2') + self.assertRaises(PackagingOptionError, cmd.ensure_filename, 'option2') def test_ensure_dirname(self): cmd = self.cmd cmd.option1 = os.path.dirname(__file__) or os.curdir cmd.ensure_dirname('option1') cmd.option2 = 'xxx' - self.assertRaises(DistutilsOptionError, cmd.ensure_dirname, 'option2') + self.assertRaises(PackagingOptionError, cmd.ensure_dirname, 'option2') + def test_suite(): return unittest.makeSuite(CommandTestCase) if __name__ == '__main__': - run_unittest(test_suite()) + unittest.main(defaultTest='test_suite') |
