Skip to content

Commit f7eadb7

Browse files
committed
revisit tests
1 parent 6de3e14 commit f7eadb7

File tree

1 file changed

+49
-31
lines changed

1 file changed

+49
-31
lines changed

testing/test_doctest.py

Lines changed: 49 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -292,45 +292,63 @@ def test(self):
292292
)
293293

294294
def test_doctest_linedata_on_property(self, testdir):
295-
testdir.tmpdir.join("hello.py").write(
296-
textwrap.dedent(
297-
"""\
298-
class Sample(object):
299-
@property
300-
def some_property(self):
301-
'''
302-
>>> Sample().some_property
303-
'another thing'
304-
'''
305-
return 'something'
306-
"""
307-
)
295+
testdir.makepyfile(
296+
"""
297+
class Sample(object):
298+
@property
299+
def some_property(self):
300+
'''
301+
>>> Sample().some_property
302+
'another thing'
303+
'''
304+
return 'something'
305+
"""
308306
)
309307
result = testdir.runpytest("--doctest-modules")
310-
result.stdout.fnmatch_lines(["*hello*", "005*>>> Sample().some_property"])
308+
result.stdout.fnmatch_lines(
309+
[
310+
"*= FAILURES =*",
311+
"*_ [doctest] test_doctest_linedata_on_property.Sample.some_property _*",
312+
"004 ",
313+
"005 >>> Sample().some_property",
314+
"Expected:",
315+
" 'another thing'",
316+
"Got:",
317+
" 'something'",
318+
"",
319+
"*/test_doctest_linedata_on_property.py:5: DocTestFailure",
320+
"*= 1 failed in *",
321+
]
322+
)
311323

312324
def test_doctest_no_linedata_on_overriden_property(self, testdir):
313-
testdir.tmpdir.join("hello.py").write(
314-
textwrap.dedent(
315-
"""\
316-
class Sample(object):
317-
@property
318-
def some_property(self):
319-
'''
320-
>>> Sample().some_property
321-
'another thing'
322-
'''
323-
return 'something'
324-
some_property = property(some_property.__get__, None, None, some_property.__doc__)
325-
"""
326-
)
325+
testdir.makepyfile(
326+
"""
327+
class Sample(object):
328+
@property
329+
def some_property(self):
330+
'''
331+
>>> Sample().some_property
332+
'another thing'
333+
'''
334+
return 'something'
335+
some_property = property(some_property.__get__, None, None, some_property.__doc__)
336+
"""
327337
)
328338
result = testdir.runpytest("--doctest-modules")
329339
result.stdout.fnmatch_lines(
330340
[
331-
"*hello*",
332-
"*EXAMPLE LOCATION UNKNOWN, not showing all tests of that example*",
333-
"???*>>> Sample().some_property",
341+
"*= FAILURES =*",
342+
"*_ [doctest] test_doctest_no_linedata_on_overriden_property.Sample.some_property _*",
343+
"EXAMPLE LOCATION UNKNOWN, not showing all tests of that example",
344+
"??? >>> Sample().some_property",
345+
"Expected:",
346+
" 'another thing'",
347+
"Got:",
348+
" 'something'",
349+
"",
350+
"*/test_doctest_no_linedata_on_overriden_property.py:None: DocTestFailure",
351+
"*= 1 failed in *",
334352
]
335353
)
336354

0 commit comments

Comments
 (0)