File tree 2 files changed +10
-1
lines changed
2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -64,9 +64,13 @@ def result(self) -> Any:
64
64
def cachedResult (self ) -> Any :
65
65
"""
66
66
Return the result of the last `subject` call.
67
- Use this function if when you to assert different attributes of your
67
+ Use this function when you want to assert different attributes of your
68
68
subject without executing it multiple times.
69
+
70
+ Raises `unittest_extensions.TestError` if subject has not been called.
69
71
"""
72
+ if not hasattr (self , "_subject_result" ):
73
+ raise TestError ("Cannot call 'cachedResult' before calling 'result'" )
70
74
return self ._subject_result
71
75
72
76
def assertResult (self , value ):
Original file line number Diff line number Diff line change @@ -62,6 +62,11 @@ def test_missing_arg_raises(self):
62
62
TestError , "Subject misses 1 required positional argument."
63
63
)
64
64
65
+ @args ({"a" : 1 , "b" : 2 })
66
+ def test_cachedResult_raises (self ):
67
+ with self .assertRaises (TestError ):
68
+ self .cachedResult ()
69
+
65
70
66
71
class TestAppend (TestCase ):
67
72
You can’t perform that action at this time.
0 commit comments