File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 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:
6464 def cachedResult (self ) -> Any :
6565 """
6666 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
6868 subject without executing it multiple times.
69+
70+ Raises `unittest_extensions.TestError` if subject has not been called.
6971 """
72+ if not hasattr (self , "_subject_result" ):
73+ raise TestError ("Cannot call 'cachedResult' before calling 'result'" )
7074 return self ._subject_result
7175
7276 def assertResult (self , value ):
Original file line number Diff line number Diff line change @@ -62,6 +62,11 @@ def test_missing_arg_raises(self):
6262 TestError , "Subject misses 1 required positional argument."
6363 )
6464
65+ @args ({"a" : 1 , "b" : 2 })
66+ def test_cachedResult_raises (self ):
67+ with self .assertRaises (TestError ):
68+ self .cachedResult ()
69+
6570
6671class TestAppend (TestCase ):
6772
You can’t perform that action at this time.
0 commit comments