diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-04-28 18:24:40 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-04-28 18:24:40 -0400 |
commit | 8b2364acc9025c8931d9a61b94be2268353deb12 (patch) | |
tree | 6464527427f694d2501392ddac722d94d70406f6 | |
parent | 9587cb624baae9852593a26b0ff5beaf73ad24d9 (diff) | |
download | python-coveragepy-git-8b2364acc9025c8931d9a61b94be2268353deb12.tar.gz |
Split out the cmdline.py tests.
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | test/test_cmdline.py | 41 | ||||
-rw-r--r-- | test/test_coverage.py | 30 |
3 files changed, 48 insertions, 31 deletions
@@ -20,7 +20,13 @@ clean: -rm -f $(TEST_ZIP) -rm -f setuptools-*.egg -LINTABLE_TESTS = test/test_data.py test/test_execfile.py test/test_farm.py test/coveragetest.py test/test_templite.py +LINTABLE_TESTS = \ + test/coveragetest.py \ + test/test_cmdline.py \ + test/test_data.py \ + test/test_execfile.py \ + test/test_farm.py \ + test/test_templite.py lint: clean -python -x /Python25/Scripts/pylint.bat --rcfile=.pylintrc coverage diff --git a/test/test_cmdline.py b/test/test_cmdline.py new file mode 100644 index 00000000..27fcd84e --- /dev/null +++ b/test/test_cmdline.py @@ -0,0 +1,41 @@ +"""Test cmdline.py for coverage.""" + +import unittest + +import coverage + +from coveragetest import CoverageTest + + +class CmdLineTest(CoverageTest): + def help_fn(self, error=None): + raise Exception(error or "__doc__") + + def command_line(self, argv): + return coverage.CoverageScript().command_line(argv, self.help_fn) + + def testHelp(self): + self.assertRaisesMsg(Exception, "__doc__", self.command_line, ['-h']) + self.assertRaisesMsg(Exception, "__doc__", self.command_line, ['--help']) + + def testUnknownOption(self): + self.assertRaisesMsg(Exception, "option -z not recognized", self.command_line, ['-z']) + + def testBadActionCombinations(self): + self.assertRaisesMsg(Exception, "You can't specify the 'erase' and 'annotate' options at the same time.", self.command_line, ['-e', '-a']) + self.assertRaisesMsg(Exception, "You can't specify the 'erase' and 'report' options at the same time.", self.command_line, ['-e', '-r']) + self.assertRaisesMsg(Exception, "You can't specify the 'erase' and 'combine' options at the same time.", self.command_line, ['-e', '-c']) + self.assertRaisesMsg(Exception, "You can't specify the 'execute' and 'annotate' options at the same time.", self.command_line, ['-x', '-a']) + self.assertRaisesMsg(Exception, "You can't specify the 'execute' and 'report' options at the same time.", self.command_line, ['-x', '-r']) + self.assertRaisesMsg(Exception, "You can't specify the 'execute' and 'combine' options at the same time.", self.command_line, ['-x', '-c']) + + def testNeedAction(self): + self.assertRaisesMsg(Exception, "You must specify at least one of -e, -x, -c, -r, -a, or -b.", self.command_line, ['-p']) + + def testArglessActions(self): + self.assertRaisesMsg(Exception, "Unexpected arguments: foo bar", self.command_line, ['-e', 'foo', 'bar']) + self.assertRaisesMsg(Exception, "Unexpected arguments: baz quux", self.command_line, ['-c', 'baz', 'quux']) + + +if __name__ == '__main__': + unittest.main() diff --git a/test/test_coverage.py b/test/test_coverage.py index 7d6e866a..f9f4c55f 100644 --- a/test/test_coverage.py +++ b/test/test_coverage.py @@ -1690,36 +1690,6 @@ class ApiTest(CoverageTest): -class CmdLineTest(CoverageTest): - def help_fn(self, error=None): - raise Exception(error or "__doc__") - - def command_line(self, argv): - return coverage.CoverageScript().command_line(argv, self.help_fn) - - def testHelp(self): - self.assertRaisesMsg(Exception, "__doc__", self.command_line, ['-h']) - self.assertRaisesMsg(Exception, "__doc__", self.command_line, ['--help']) - - def testUnknownOption(self): - self.assertRaisesMsg(Exception, "option -z not recognized", self.command_line, ['-z']) - - def testBadActionCombinations(self): - self.assertRaisesMsg(Exception, "You can't specify the 'erase' and 'annotate' options at the same time.", self.command_line, ['-e', '-a']) - self.assertRaisesMsg(Exception, "You can't specify the 'erase' and 'report' options at the same time.", self.command_line, ['-e', '-r']) - self.assertRaisesMsg(Exception, "You can't specify the 'erase' and 'combine' options at the same time.", self.command_line, ['-e', '-c']) - self.assertRaisesMsg(Exception, "You can't specify the 'execute' and 'annotate' options at the same time.", self.command_line, ['-x', '-a']) - self.assertRaisesMsg(Exception, "You can't specify the 'execute' and 'report' options at the same time.", self.command_line, ['-x', '-r']) - self.assertRaisesMsg(Exception, "You can't specify the 'execute' and 'combine' options at the same time.", self.command_line, ['-x', '-c']) - - def testNeedAction(self): - self.assertRaisesMsg(Exception, "You must specify at least one of -e, -x, -c, -r, -a, or -b.", self.command_line, ['-p']) - - def testArglessActions(self): - self.assertRaisesMsg(Exception, "Unexpected arguments: foo bar", self.command_line, ['-e', 'foo', 'bar']) - self.assertRaisesMsg(Exception, "Unexpected arguments: baz quux", self.command_line, ['-c', 'baz', 'quux']) - - class ProcessTest(CoverageTest): def testSaveOnExit(self): self.makeFile("mycode", """\ |