File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,6 +36,29 @@ def test_multiple_chain_branches_on_same_root_are_supported():
3636 assert cat_that_meowed .roll () == "playful"
3737
3838
39+ def test_unstub_child_chain_then_reconfigure_does_not_leave_stale_root_stub ():
40+ cat = mock ()
41+
42+ when (cat ).meow ().purr ().sleep ().thenReturn ("base" )
43+ when (cat ).meow ().purr ().sleep ().thenReturn ("override" )
44+
45+ with when (cat ).meow ().purr ():
46+ cat .meow ().purr ()
47+
48+ with pytest .raises (InvocationError ) as exc :
49+ with when (cat ).meow ().purr ().thenReturn ("tmp" ):
50+ cat .meow ().purr ()
51+
52+ assert str (exc .value ) == "'purr' is already configured for chained stubbing."
53+
54+ unstub (cat .meow ())
55+
56+ with when (cat ).meow ().purr ().thenReturn ("tmp" ):
57+ assert cat .meow ().purr () == "tmp"
58+
59+ assert cat .meow () is None
60+
61+
3962def test_expectation_on_chain_applies_to_leaf ():
4063 cat = mock ()
4164
You can’t perform that action at this time.
0 commit comments