Ejemplo n.º 1
0
 def test_splat_args(self):
     self.assertTrue(
         self.mock_expecting(*any_args)._satisfied_by([Call.like(1, 2, 3)]))
     self.assertTrue(
         self.mock_expecting(*args_containing(1))._satisfied_by(
             [Call.like(1, 2, 3)]))
     self.assertTrue(
         self.mock_expecting(*args_containing(1))._satisfied_by(
             [Call.like(2, 1, 3)]))
     self.assertFalse(
         self.mock_expecting(*args_containing(1))._satisfied_by(
             [Call.like(2, 2, 3)]))
     self.assertFalse(
         self.mock_expecting(1, 2, *args_containing(1))._satisfied_by(
             [Call.like(1, 2, 4, 3)]))
Ejemplo n.º 2
0
 def test_matching_only_some_args(self):
     when(obj).foo(*args_containing(1, 2)).then_return(True)
     assert obj.foo(1, 4, 3, 2)
     assert obj.foo(1, 2)
     self.assertRaises(TypeError, lambda: obj.foo(1))
Ejemplo n.º 3
0
 def test_using_splats_is_enforced_for_args(self):
     self.assertRaises(
         RuntimeError,
         lambda: when(obj).foo(args_containing(1)),
         message="SplatMatcher instance used without prefixing with '*'")
Ejemplo n.º 4
0
 def test_splat_args(self):
     self.assertTrue(self.mock_expecting(*any_args)._satisfied_by([Call.like(1, 2, 3)]))
     self.assertTrue(self.mock_expecting(*args_containing(1))._satisfied_by([Call.like(1, 2, 3)]))
     self.assertTrue(self.mock_expecting(*args_containing(1))._satisfied_by([Call.like(2, 1, 3)]))
     self.assertFalse(self.mock_expecting(*args_containing(1))._satisfied_by([Call.like(2, 2, 3)]))
     self.assertFalse(self.mock_expecting(1, 2, *args_containing(1))._satisfied_by([Call.like(1, 2, 4, 3)]))
Ejemplo n.º 5
0
 def test_matching_only_some_args(self):
     when(obj).foo(*args_containing(1, 2)).then_return(True)
     assert obj.foo(1, 4, 3, 2)
     assert obj.foo(1, 2)
     self.assertRaises(TypeError, lambda: obj.foo(1))
Ejemplo n.º 6
0
 def test_using_splats_is_enforced_for_args(self):
     self.assertRaises(
         RuntimeError,
         lambda: when(obj).foo(args_containing(1)),
         message="SplatMatcher instance used without prefixing with '*'",
     )