Exemple #1
0
def test_mock_assert_called_with_can_fail():
    test_object = Mock()

    test_object.method({'bob': 'barker'})

    with pytest.raises(AssertionError):
        test_object.method.assert_called_with(instance_of(list))
Exemple #2
0
 def test_equals_same_type_with_multiple_types(self):
     assert instance_of(dict, tuple) == (1, 2)
Exemple #3
0
 def test_equals_same_type(self):
     assert instance_of(dict) == {}
Exemple #4
0
 def test__eq__that_returns_not_implemented_two(self):
     test_obj = instance_of(EqualsNotImplemented).with_attrs(
         name="Bob Barker", )
     assert test_obj == EqualsNotImplemented("Bob Barker")
Exemple #5
0
 def test_poorly_implemented__eq__(self):
     test_obj = instance_of(NeverEquals).with_attrs(name="Bob Barker", )
     assert test_obj == NeverEquals("Bob Barker")
Exemple #6
0
 def test_does_not_equal_instance_of_wrong_type(self):
     test_obj = instance_of(dict).with_attrs(foo='bar', bob='barker')
     assert not test_obj == Dummy('bar', 'barker')
Exemple #7
0
 def test_equals_instance_of_correct_type(self):
     test_obj = instance_of(Dummy).with_attrs(foo='bar', bob='barker')
     assert test_obj == Dummy('bar', 'barker')
Exemple #8
0
def test_mock_assert_called_with_passes():
    test_object = Mock()

    test_object.method({'bob': 'barker'})

    test_object.method.assert_called_with(instance_of(dict))
Exemple #9
0
 def test_order_of_test_does_not_matter(self):
     assert object() == instance_of(object)
Exemple #10
0
 def test_equals_same_type_with_multiple_types(self):
     assert instance_of(dict, tuple) == (1, 2)
Exemple #11
0
 def test_equals_same_type(self):
     assert instance_of(dict) == {}
Exemple #12
0
 def test__eq__that_returns_not_implemented_two(self):
     test_obj = instance_of(EqualsNotImplemented).with_attrs(
         name="Bob Barker",
     )
     assert test_obj == EqualsNotImplemented("Bob Barker")
Exemple #13
0
 def test_poorly_implemented__eq__(self):
     test_obj = instance_of(NeverEquals).with_attrs(
         name="Bob Barker",
     )
     assert test_obj == NeverEquals("Bob Barker")
Exemple #14
0
 def test_does_not_equal_instance_of_wrong_type(self):
     test_obj = instance_of(dict).with_attrs(foo='bar', bob='barker')
     assert not test_obj == Dummy('bar', 'barker')
Exemple #15
0
 def test_equals_instance_of_correct_type(self):
     test_obj = instance_of(Dummy).with_attrs(foo='bar', bob='barker')
     assert test_obj == Dummy('bar', 'barker')
Exemple #16
0
 def test_order_of_test_does_not_matter(self):
     assert object() == instance_of(object)
Exemple #17
0
 def test_representation(self):
     test_obj = instance_of(dict)
     expected = r"Any instance of <(type|class) 'dict'>"
     assert re.match(expected, str(test_obj))
     assert re.match('<Equals {}>'.format(expected), repr(test_obj))
Exemple #18
0
 def test_representation(self):
     test_obj = instance_of(dict)
     expected = r"Any instance of <(type|class) 'dict'>"
     assert re.match(expected, str(test_obj))
     assert re.match('<Equals {}>'.format(expected), repr(test_obj))