File tree 3 files changed +14
-2
lines changed 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change
1
+ Allow ``CallInfo `` to have an unfinished state represented by having a ``None `` value in the ``result `` attribute.
Original file line number Diff line number Diff line change @@ -224,7 +224,8 @@ def __repr__(self):
224
224
if self .excinfo :
225
225
status = "exception: %s" % str (self .excinfo .value )
226
226
else :
227
- status = "result: %r" % (self .result ,)
227
+ result = getattr (self , "result" , "<NOTSET>" )
228
+ status = "result: %r" % (result ,)
228
229
return "<CallInfo when=%r %s>" % (self .when , status )
229
230
230
231
Original file line number Diff line number Diff line change @@ -493,11 +493,21 @@ def test_callinfo():
493
493
assert "result" in repr (ci )
494
494
ci = runner .CallInfo (lambda : 0 / 0 , "123" )
495
495
assert ci .when == "123"
496
- assert not hasattr ( ci , " result" )
496
+ assert ci . result is None
497
497
assert ci .excinfo
498
498
assert "exc" in repr (ci )
499
499
500
500
501
+ def test_callinfo_repr_while_running ():
502
+ def repr_while_running ():
503
+ f = sys ._getframe ().f_back
504
+ assert "func" in f .f_locals
505
+ assert repr (f .f_locals ["self" ]) == "<CallInfo when='when' result: '<NOTSET>'>"
506
+
507
+ ci = runner .CallInfo (repr_while_running , "when" )
508
+ assert repr (ci ) == "<CallInfo when='when' result: None>"
509
+
510
+
501
511
# design question: do we want general hooks in python files?
502
512
# then something like the following functional tests makes sense
503
513
You can’t perform that action at this time.
0 commit comments