Esempio n. 1
0
 def test_del(self):
     o = OrderedProperties()
     assert 'a' not in o
     o.a = 1
     assert 'a' in o
     del o.a
     assert 'a' not in o
Esempio n. 2
0
 def test_del_item(self):
     o = OrderedProperties()
     assert 'a' not in o
     o.a = 1
     assert 'a' in o
     del o['a']
     assert 'a' not in o
 def test_del(self):
     o = OrderedProperties()
     assert 'a' not in o
     o.a = 1
     assert 'a' in o
     del o.a
     assert 'a' not in o
 def test_del_item(self):
     o = OrderedProperties()
     assert 'a' not in o
     o.a = 1
     assert 'a' in o
     del o['a']
     assert 'a' not in o
Esempio n. 5
0
    def test_update(self):
        o = OrderedProperties()
        o.a = 1
        o.update(dict(b=2))
        assert o.b == 2

        assert list(o) == [1, 2]
    def test_update(self):
        o = OrderedProperties()
        o.a = 1
        o.update(dict(b=2))
        assert o.b == 2

        assert list(o) == [1, 2]
 def test_basics(self):
     o = OrderedProperties()
     o.a = 1
     o.b = 2
     for i, attr in enumerate(o):
         if i == 0:
             assert attr == 1
         else:
             assert attr == 2
Esempio n. 8
0
 def test_basics(self):
     o = OrderedProperties()
     o.a = 1
     o.b = 2
     for i, attr in enumerate(o):
         if i == 0:
             assert attr == 1
         else:
             assert attr == 2
Esempio n. 9
0
    def test_pickle(self):
        o = OrderedProperties()
        o.a = 1
        o.b = 2

        ostr = pickle.dumps(o, pickle.HIGHEST_PROTOCOL)
        po = pickle.loads(ostr)

        assert po.a == 1
        assert po.b == 2
        assert list(po) == [1, 2]
Esempio n. 10
0
    def test_pickle(self):
        o = OrderedProperties()
        o.a = 1
        o.b = 2

        ostr = pickle.dumps(o, pickle.HIGHEST_PROTOCOL)
        po = pickle.loads(ostr)

        assert po.a == 1
        assert po.b == 2
        assert list(po) == [1, 2]
Esempio n. 11
0
    def test_initilization(self):
        o = OrderedProperties(initialize=False)
        o.a = 1
        o._initialized = True
        o.b = 2

        assert o.a == 1
        assert list(o) == [2]

        del o.a

        try:
            o.a
            assert False, 'expected exception'
        except AttributeError:
            pass
Esempio n. 12
0
    def test_initilization(self):
        o = OrderedProperties(initialize=False)
        o.a = 1
        o._initialized = True
        o.b = 2

        assert o.a == 1
        assert list(o) == [2]

        del o.a

        try:
            o.a
            assert False, 'expected exception'
        except AttributeError:
            pass
Esempio n. 13
0
    def test_add(self):
        o1 = OrderedProperties()
        o2 = OrderedProperties()

        o1.a = 1
        o1.c = 3
        o2.b = 2
        o2.d = 4

        result = o1 + o2

        assert result == [1, 3, 2, 4]
Esempio n. 14
0
    def test_add(self):
        o1 = OrderedProperties()
        o2 = OrderedProperties()

        o1.a = 1
        o1.c = 3
        o2.b = 2
        o2.d = 4

        result = o1 + o2

        assert result == [1, 3, 2, 4]
Esempio n. 15
0
 def test_del_attribute_error(self):
     o = OrderedProperties()
     with pytest.raises(AttributeError, match='foo'):
         del o.foo
Esempio n. 16
0
 def test_has_key(self):
     o = OrderedProperties()
     o.a = 1
     assert 'a' in o
Esempio n. 17
0
 def test_clear(self):
     o = OrderedProperties()
     o.a = 1
     assert 'a' in o
     o.clear()
     assert 'a' not in o
Esempio n. 18
0
    def test_list(self):
        o = OrderedProperties()
        o.a = 1
        o.b = 2

        assert list(o) == [1, 2]
Esempio n. 19
0
    def test_list(self):
        o = OrderedProperties()
        o.a = 1
        o.b = 2

        assert list(o) == [1, 2]
Esempio n. 20
0
 def test_clear(self):
     o = OrderedProperties()
     o.a = 1
     assert 'a' in o
     o.clear()
     assert 'a' not in o
Esempio n. 21
0
 def test_has_key(self):
     o = OrderedProperties()
     o.a = 1
     assert 'a' in o
Esempio n. 22
0
 def __init__(self, initialize=True):
     self._locked = False
     OrderedProperties.__init__(self, initialize)
Esempio n. 23
0
 def __init__(self, initialize=True):
     self._locked = False
     OrderedProperties.__init__(self, initialize)