diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2013-10-19 21:21:10 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2013-10-19 21:21:10 -0400 |
commit | d141a36502ff40891959048c7154c2f954dd2d13 (patch) | |
tree | f61b37c6a5857977c1e0269bf825dc51277b2f5d /tests/test_oddball.py | |
parent | 0e1fc29ed05295f60bc9512ed9a516ff024de144 (diff) | |
download | python-coveragepy-d141a36502ff40891959048c7154c2f954dd2d13.tar.gz |
We only run on 2.6, 2.7, 3.2, 3.3 now.
Diffstat (limited to 'tests/test_oddball.py')
-rw-r--r-- | tests/test_oddball.py | 73 |
1 files changed, 36 insertions, 37 deletions
diff --git a/tests/test_oddball.py b/tests/test_oddball.py index 4b18a4e..eba507b 100644 --- a/tests/test_oddball.py +++ b/tests/test_oddball.py @@ -329,43 +329,42 @@ class ExceptionTest(CoverageTest): self.assertEqual(clean_lines, lines_expected) -if sys.version_info >= (2, 5): - class DoctestTest(CoverageTest): - """Tests invoked with doctest should measure properly.""" - - def setUp(self): - super(DoctestTest, self).setUp() - - # Oh, the irony! This test case exists because Python 2.4's - # doctest module doesn't play well with coverage. But nose fixes - # the problem by monkeypatching doctest. I want to undo the - # monkeypatch to be sure I'm getting the doctest module that users - # of coverage will get. Deleting the imported module here is - # enough: when the test imports doctest again, it will get a fresh - # copy without the monkeypatch. - del sys.modules['doctest'] - - def test_doctest(self): - self.check_coverage('''\ - def return_arg_or_void(arg): - """If <arg> is None, return "Void"; otherwise return <arg> - - >>> return_arg_or_void(None) - 'Void' - >>> return_arg_or_void("arg") - 'arg' - >>> return_arg_or_void("None") - 'None' - """ - if arg is None: - return "Void" - else: - return arg - - import doctest, sys - doctest.testmod(sys.modules[__name__]) # we're not __main__ :( - ''', - [1,11,12,14,16,17], "") +class DoctestTest(CoverageTest): + """Tests invoked with doctest should measure properly.""" + + def setUp(self): + super(DoctestTest, self).setUp() + + # Oh, the irony! This test case exists because Python 2.4's + # doctest module doesn't play well with coverage. But nose fixes + # the problem by monkeypatching doctest. I want to undo the + # monkeypatch to be sure I'm getting the doctest module that users + # of coverage will get. Deleting the imported module here is + # enough: when the test imports doctest again, it will get a fresh + # copy without the monkeypatch. + del sys.modules['doctest'] + + def test_doctest(self): + self.check_coverage('''\ + def return_arg_or_void(arg): + """If <arg> is None, return "Void"; otherwise return <arg> + + >>> return_arg_or_void(None) + 'Void' + >>> return_arg_or_void("arg") + 'arg' + >>> return_arg_or_void("None") + 'None' + """ + if arg is None: + return "Void" + else: + return arg + + import doctest, sys + doctest.testmod(sys.modules[__name__]) # we're not __main__ :( + ''', + [1,11,12,14,16,17], "") if hasattr(sys, 'gettrace'): |