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))
def test_equals_same_type_with_multiple_types(self): assert instance_of(dict, tuple) == (1, 2)
def test_equals_same_type(self): assert instance_of(dict) == {}
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")
def test_poorly_implemented__eq__(self): test_obj = instance_of(NeverEquals).with_attrs(name="Bob Barker", ) assert test_obj == NeverEquals("Bob Barker")
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')
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')
def test_mock_assert_called_with_passes(): test_object = Mock() test_object.method({'bob': 'barker'}) test_object.method.assert_called_with(instance_of(dict))
def test_order_of_test_does_not_matter(self): assert object() == instance_of(object)
def test_poorly_implemented__eq__(self): test_obj = instance_of(NeverEquals).with_attrs( name="Bob Barker", ) assert test_obj == NeverEquals("Bob Barker")
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))