File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Expand file tree Collapse file tree 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):
224224 if self .excinfo :
225225 status = "exception: %s" % str (self .excinfo .value )
226226 else :
227- status = "result: %r" % (self .result ,)
227+ result = getattr (self , "result" , "<NOTSET>" )
228+ status = "result: %r" % (result ,)
228229 return "<CallInfo when=%r %s>" % (self .when , status )
229230
230231
Original file line number Diff line number Diff line change @@ -493,11 +493,21 @@ def test_callinfo():
493493 assert "result" in repr (ci )
494494 ci = runner .CallInfo (lambda : 0 / 0 , "123" )
495495 assert ci .when == "123"
496- assert not hasattr ( ci , " result" )
496+ assert ci . result is None
497497 assert ci .excinfo
498498 assert "exc" in repr (ci )
499499
500500
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+
501511# design question: do we want general hooks in python files?
502512# then something like the following functional tests makes sense
503513
You can’t perform that action at this time.
0 commit comments