@@ -287,13 +287,68 @@ def test(self):
287
287
)
288
288
)
289
289
result = testdir .runpytest ("--doctest-modules" )
290
+ result .stdout .fnmatch_lines (
291
+ ["*hello*" , "006*>>> 1/0*" , "*UNEXPECTED*ZeroDivision*" , "*1 failed*" ]
292
+ )
293
+
294
+ def test_doctest_linedata_on_property (self , testdir ):
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
+ """
306
+ )
307
+ result = testdir .runpytest ("--doctest-modules" )
290
308
result .stdout .fnmatch_lines (
291
309
[
292
- "*hello*" ,
293
- "*EXAMPLE LOCATION UNKNOWN, not showing all tests of that example*" ,
294
- "*1/0*" ,
295
- "*UNEXPECTED*ZeroDivision*" ,
296
- "*1 failed*" ,
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
+ )
323
+
324
+ def test_doctest_no_linedata_on_overriden_property (self , testdir ):
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
+ """
337
+ )
338
+ result = testdir .runpytest ("--doctest-modules" )
339
+ result .stdout .fnmatch_lines (
340
+ [
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 *" ,
297
352
]
298
353
)
299
354
0 commit comments