Ejemplo n.º 1
0
    def test_it_matches_with_attributes_correctly(self, attributes, matches):
        other = ValueObject(one="one", two="two")

        if matches:
            assert other == AnyObject.with_attrs(attributes)
        else:
            assert other != AnyObject.with_attrs(attributes)
Ejemplo n.º 2
0
    def test_it_mocks_attributes(self):
        matcher = AnyObject.with_attrs({"a": "A"})

        assert matcher.a == "A"

        with pytest.raises(AttributeError):
            matcher.b  # pylint: disable=pointless-statement
Ejemplo n.º 3
0
    def test_setting_magic_methods_as_attributes_does_not_set_attributes(
            self, magic_method):
        # There's no sensible reason to do it, but we should still be able to
        # function normally if you do.

        weird_matcher = AnyObject.with_attrs({magic_method: "test"})

        result = getattr(weird_matcher, magic_method)

        assert callable(result)
Ejemplo n.º 4
0
 def test_it_raise_ValueError_if_attributes_does_not_support_items(
         self, bad_input):
     with pytest.raises(ValueError):
         AnyObject.with_attrs(bad_input)