Beispiel #1
1
 def test_string_substitute(self):
     w = Wax()
     w.foo = 1
     w.bar = Wax()
     w.bar.baz = 1
     self.assertEquals('1 = 1', '%(foo)s = %(bar.baz)s'.__mod__(w))
Beispiel #2
0
    def test_rewrites(self):
        for v1, v2 in T_REWRITES:
            w = Wax()
            w.key = v1
            w.key = v2

        # ensure that values that are instances of builtin types can be
        # replaced with classes which inherit from a compatible type, and vice
        # versa.
        class Foo(str):
            pass

        fstr = Foo("hi")
        w = Wax()
        w.foo = "hello"
        w.foo = fstr
        w.foo = "goodbye"
Beispiel #3
0
    def test_rewrites(self):
        for v1, v2 in T_REWRITES:
            w = Wax()
            w.key = v1
            w.key = v2

        # ensure that values that are instances of builtin types can be
        # replaced with classes which inherit from a compatible type, and vice
        # versa.
        class Foo(str): 
            pass

        fstr = Foo("hi")
        w = Wax()
        w.foo = "hello"
        w.foo = fstr
        w.foo = "goodbye"
Beispiel #4
0
 def test_iterate(self):
     w = Wax()
     w.foo = 1
     w.bar = 2
     w.abc = 3
     w.xyz = 4
     keys = []
     for key in w:
         keys.append(key)
     self.assertEquals(['foo', 'bar', 'abc', 'xyz'], keys)
Beispiel #5
0
 def test_basic(self):
     w = Wax()
     w.foo = 1
     w.bar = 2
     w.group1 = Wax()
     w.group1.foo = 1
     self.assertEquals(w.foo, 1)
     self.assertEquals(w.bar, 2)
     self.assertEquals(w.group1.foo, 1)
     self.assertEquals(w['group1.foo'], 1)
Beispiel #6
0
 def test_basic(self):
     w = Wax()
     w.foo = 1
     w.bar = 2
     w.group1 = Wax()
     w.group1.foo = 1
     self.assertEquals(w.foo, 1)
     self.assertEquals(w.bar, 2)
     self.assertEquals(w.group1.foo, 1)
     self.assertEquals(w['group1.foo'], 1)
Beispiel #7
0
 def test_iterate(self):
     w = Wax()
     w.foo=1
     w.bar=2
     w.abc=3
     w.xyz=4
     keys = []
     for key in w:
         keys.append(key)
     self.assertEquals(['foo','bar','abc','xyz'], keys)
Beispiel #8
0
 def test_parse_append(self):
     w = Wax()
     w.foo = 1
     w += parse_wax('bar = 2\n[one.two]\nkey = "val"')
     self.assertEquals(w.bar, 2)
     self.assertEquals(w.one.two.key, "val")
Beispiel #9
0
 def test_bad_select(self):
     w = Wax()
     w.foo = 1
     self.assertRaises(WaxError, w.__getitem__, 'foo.bar')
Beispiel #10
0
 def test_string_substitute(self):
     w = Wax()
     w.foo = 1
     w.bar = Wax()
     w.bar.baz = 1
     self.assertEquals('1 = 1', '%(foo)s = %(bar.baz)s'.__mod__(w))
Beispiel #11
0
 def test_parse_append(self):
     w = Wax()
     w.foo = 1
     w += parse_wax('bar = 2\n[one.two]\nkey = "val"')
     self.assertEquals(w.bar, 2)
     self.assertEquals(w.one.two.key, "val")
Beispiel #12
0
 def test_bad_select(self):
     w = Wax()
     w.foo = 1
     self.assertRaises(WaxError, w.__getitem__, 'foo.bar')