Exemplo n.º 1
0
    def test_iterkeys(self):
        assert sorted(iterkeys(OpenStruct())) == []

        o = OpenStruct({'foo': 123})
        assert sorted(iterkeys(o)) == sorted(o.keys())

        o['bar'] = 456
        assert sorted(iterkeys(o)) == sorted(o.keys())
Exemplo n.º 2
0
    def test_iter(self):
        assert [x for x in OpenStruct()] == []

        o = OpenStruct({'foo': 'hello'})
        assert sorted([x for x in o]) == sorted(o.keys())

        o['bar'] = 123
        assert sorted([x for x in o]) == sorted(o.keys())
Exemplo n.º 3
0
    def test_keys(self):
        assert sorted(OpenStruct().keys()) == []

        o = OpenStruct({'foo': 1, 'bar': 2})
        assert sorted(o.keys()) == sorted(['foo', 'bar'])

        o['baz'] = 2
        assert sorted(o.keys()) == sorted(['foo', 'bar', 'baz'])