File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 1+ Fix ``CallInfo.__repr__ `` for when the call is not finished yet.
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 @@ -491,13 +491,26 @@ def test_callinfo():
491491 assert ci .when == "123"
492492 assert ci .result == 0
493493 assert "result" in repr (ci )
494+ assert repr (ci ) == "<CallInfo when='123' result: 0>"
495+
494496 ci = runner .CallInfo (lambda : 0 / 0 , "123" )
495497 assert ci .when == "123"
496498 assert not hasattr (ci , "result" )
499+ assert repr (ci ) == "<CallInfo when='123' exception: division by zero>"
497500 assert ci .excinfo
498501 assert "exc" in repr (ci )
499502
500503
504+ def test_callinfo_repr_while_running ():
505+ def repr_while_running ():
506+ f = sys ._getframe ().f_back
507+ assert "func" in f .f_locals
508+ assert repr (f .f_locals ["self" ]) == "<CallInfo when='when' result: '<NOTSET>'>"
509+
510+ ci = runner .CallInfo (repr_while_running , "when" )
511+ assert repr (ci ) == "<CallInfo when='when' result: None>"
512+
513+
501514# design question: do we want general hooks in python files?
502515# then something like the following functional tests makes sense
503516
You can’t perform that action at this time.
0 commit comments