def test_object_keys(self):
        """
            Test that object keys work. The point of object keys is that they can
            have multiple paths of eq() check. A regular dictionary will check 
            using is or hash(self) == hash(other). We turn this check into eq(self, other). 

            This means we can use keys that can have multiple types of equivalencies.
        """
        d = attrdict()
        k = TestKey('dale', 111)
        d[k] = 'test'
        k = TestKey('dale2', 112)
        o = object()
        d[k] = o

        assert d.dale == 'test'
        assert d[111] == 'test'
        assert d['dale'] == 'test'

        assert d[112] is d['dale2']
Beispiel #2
0
    def test_object_keys(self):
        """
            Test that object keys work. The point of object keys is that they can
            have multiple paths of eq() check. A regular dictionary will check 
            using is or hash(self) == hash(other). We turn this check into eq(self, other). 

            This means we can use keys that can have multiple types of equivalencies.
        """
        d = attrdict()
        k = TestKey('dale', 111)
        d[k] = 'test'
        k = TestKey('dale2', 112)
        o = object()
        d[k] = o

        assert d.dale == 'test'
        assert d[111] == 'test'
        assert d['dale'] == 'test'

        assert d[112] is d['dale2']
 def test_string_keys(self):
     d = attrdict()
     d['dale'] = 123
     assert d.dale == 123
     assert d['dale'] == 123
Beispiel #4
0
 def test_string_keys(self):
     d = attrdict()
     d['dale'] = 123
     assert d.dale == 123
     assert d['dale'] == 123