Beispiel #1
0
    def test_annotations(self):
        inp = '; one\n; two\n[foo]\n; three\nval1 = 123'
        w = parse_wax(inp)
        self.assertEquals(w._get_annotation('foo'), ' one\n two')
        self.assertEquals(w._annotations['foo'], ' one\n two')
        del w.foo.val1
        self.assertTrue('val1' not in w.foo._annotations)

        w = parse_wax(WELLFORMED)
        self.assertEquals(w.one._get_annotation('bar'), ' C 1\n C 2')
        self.assertEquals(w.one._annotations['bar'], ' C 1\n C 2')

        # make sure annotations are formatted in output
        out = str(w)
        self.assertTrue('; C 1\n; C 2\n' in out)

        # test for missing annotations
        self.assertEquals(w._get_annotation('xxxxxxx'), None)
        self.assertEquals(w._get_annotation('zzzzzzz', 'foo'), 'foo')

        # test for bad annotation type
        self.assertRaises(WaxError, w._set_annotation, 'foo', 123)

        # check removal
        w = Wax()
        w.a = 123
        w._set_annotation('a', 'hi there')
        self.assertEquals(w._get_annotation('a'), 'hi there')
        w._remove_annotation('a')
        self.assertEquals(w._annotations, {})
Beispiel #2
0
    def test_annotations(self):
        inp = '; one\n; two\n[foo]\n; three\nval1 = 123'
        w = parse_wax(inp)
        self.assertEquals(w._get_annotation('foo'), ' one\n two')
        self.assertEquals(w._annotations['foo'], ' one\n two')
        del w.foo.val1
        self.assertTrue('val1' not in w.foo._annotations)

        w = parse_wax(WELLFORMED)
        self.assertEquals(w.one._get_annotation('bar'), ' C 1\n C 2')
        self.assertEquals(w.one._annotations['bar'], ' C 1\n C 2')

        # make sure annotations are formatted in output
        out = str(w)
        self.assertTrue('; C 1\n; C 2\n' in out)

        # test for missing annotations
        self.assertEquals(w._get_annotation('xxxxxxx'), None)
        self.assertEquals(w._get_annotation('zzzzzzz', 'foo'), 'foo')

        # test for bad annotation type
        self.assertRaises(WaxError, w._set_annotation, 'foo', 123)

        # check removal
        w = Wax()
        w.a = 123
        w._set_annotation('a', 'hi there')
        self.assertEquals(w._get_annotation('a'), 'hi there')
        w._remove_annotation('a')
        self.assertEquals(w._annotations, {})
Beispiel #3
0
 def test_keys(self):
     w = Wax()
     w.a = 1
     w.z = 2
     w.c = 3
     w.b = 4
     self.assertEquals(w.keys(), ['a', 'z', 'c', 'b'])
Beispiel #4
0
 def test_keys(self):
     w = Wax()
     w.a = 1
     w.z = 2
     w.c = 3
     w.b = 4
     self.assertEquals(w.keys(), ['a','z','c','b'])