def test_splat_kwargs(self): self.assertTrue( self.mock_expecting(**any_kwargs)._satisfied_by([Call.like()])) self.assertTrue( self.mock_expecting(**any_kwargs)._satisfied_by([Call.like(x=1)])) self.assertTrue( self.mock_expecting(**kwargs_containing(x=1))._satisfied_by( [Call.like(x=1, y=2)])) self.assertFalse( self.mock_expecting(**kwargs_containing(x=1))._satisfied_by( [Call.like(y=2)]))
def test_using_splats_is_enforced_for_kwargs(self): self.assertRaises( RuntimeError, lambda: when(obj).foo(kwargs_containing(x=1)), message="KwargsMatcher instance used without prefixing with '**'")
def test_matching_only_some_kwargs(self): when(obj).foo(**kwargs_containing(x=1)).then_return(True) assert obj.foo(x=1) assert obj.foo(x=1, y=2) self.assertRaises(TypeError, lambda: obj.foo(x=3))
def test_splat_kwargs(self): self.assertTrue(self.mock_expecting(**any_kwargs)._satisfied_by([Call.like()])) self.assertTrue(self.mock_expecting(**any_kwargs)._satisfied_by([Call.like(x=1)])) self.assertTrue(self.mock_expecting(**kwargs_containing(x=1))._satisfied_by([Call.like(x=1, y=2)])) self.assertFalse(self.mock_expecting(**kwargs_containing(x=1))._satisfied_by([Call.like(y=2)]))
def test_using_splats_is_enforced_for_kwargs(self): self.assertRaises( RuntimeError, lambda: when(obj).foo(kwargs_containing(x=1)), message="KwargsMatcher instance used without prefixing with '**'", )