diff options
author | Bruno Oliveira <nicoddemus@gmail.com> | 2017-11-03 16:37:18 -0200 |
---|---|---|
committer | Bruno Oliveira <nicoddemus@gmail.com> | 2017-11-03 16:37:18 -0200 |
commit | f3a119c06a8197ac986241e800beabfa63725f54 (patch) | |
tree | 94bb03da841d3024531a07c708572268cd432b77 /testing/test_doctest.py | |
parent | cb30848e5a2ec55d9d5c9548879559e3f370a76e (diff) | |
download | pytest-f3a119c06a8197ac986241e800beabfa63725f54.tar.gz |
Merge upstream/master into features
Diffstat (limited to 'testing/test_doctest.py')
-rw-r--r-- | testing/test_doctest.py | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/testing/test_doctest.py b/testing/test_doctest.py index b8fa1fb77..b15067f15 100644 --- a/testing/test_doctest.py +++ b/testing/test_doctest.py @@ -173,7 +173,7 @@ class TestDoctests(object): "*UNEXPECTED*ZeroDivision*", ]) - def test_docstring_context_around_error(self, testdir): + def test_docstring_partial_context_around_error(self, testdir): """Test that we show some context before the actual line of a failing doctest. """ @@ -199,7 +199,7 @@ class TestDoctests(object): ''') result = testdir.runpytest('--doctest-modules') result.stdout.fnmatch_lines([ - '*docstring_context_around_error*', + '*docstring_partial_context_around_error*', '005*text-line-3', '006*text-line-4', '013*text-line-11', @@ -213,6 +213,32 @@ class TestDoctests(object): assert 'text-line-2' not in result.stdout.str() assert 'text-line-after' not in result.stdout.str() + def test_docstring_full_context_around_error(self, testdir): + """Test that we show the whole context before the actual line of a failing + doctest, provided that the context is up to 10 lines long. + """ + testdir.makepyfile(''' + def foo(): + """ + text-line-1 + text-line-2 + + >>> 1 + 1 + 3 + """ + ''') + result = testdir.runpytest('--doctest-modules') + result.stdout.fnmatch_lines([ + '*docstring_full_context_around_error*', + '003*text-line-1', + '004*text-line-2', + '006*>>> 1 + 1', + 'Expected:', + ' 3', + 'Got:', + ' 2', + ]) + def test_doctest_linedata_missing(self, testdir): testdir.tmpdir.join('hello.py').write(_pytest._code.Source(""" class Fun(object): |