From d40d77432c71d8eaa6bbc1dfb908fbcd4fe2bbb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20H=E1=BB=93ng=20Qu=C3=A2n?= Date: Mon, 24 Jul 2017 23:07:45 +0700 Subject: [PATCH] Add test case for DoctestItem.reportinfo() --- testing/test_doctest.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/testing/test_doctest.py b/testing/test_doctest.py index dd444569c..8a81ea0ed 100644 --- a/testing/test_doctest.py +++ b/testing/test_doctest.py @@ -545,6 +545,22 @@ class TestDoctests(object): result = testdir.runpytest(p, '--doctest-modules') result.stdout.fnmatch_lines(['* 1 passed *']) + def test_reportinfo(self, testdir): + ''' + Test case to make sure that DoctestItem.reportinfo() returns lineno. + ''' + p = testdir.makepyfile(test_reportinfo=""" + def foo(x): + ''' + >>> foo('a') + 'b' + ''' + return 'c' + """) + items, reprec = testdir.inline_genitems(p, '--doctest-modules') + reportinfo = items[0].reportinfo() + assert reportinfo[1] == 1 + class TestLiterals(object):