@@ -0,0 +1,2355 @@
+import unittest%0A%0Arules = '''%0A%3CLabel%3E:%0A    title: 'invalid'%0A%3CTestWidget%3E:%0A    source: 'invalid.png'%0A%0A%3CTestWidget2%3E:%0A    source: 'invalid.png'%0A    source3: 'valid.png'%0A%0A%5BItem@TestWidget2%5D:%0A    source: ctx.get('anotherctxvalue')%0A%0A%3CMainWidget%3E:%0A    refwid: myref%0A    refwid2: myref2%0A    Item:%0A        id: myref2%0A        anotherctxvalue: 'valid.png'%0A    TestWidget:%0A        canvas:%0A            Color:%0A                rgba: 1, 1, 1, 1%0A        id: myref%0A        source: 'valid.png'%0A        source2: 'valid.png'%0A        source3: self.source + 'from source3' if self.can_edit else 'valid.png'%0A        on_release: root.edit()%0A        Label:%0A            title: 'valid'%0A'''%0A%0Aclass LangComplexTestCase(unittest.TestCase):%0A%0A    def test_complex_rewrite(self):%0A        # this test cover a large part of the lang%0A        # and was used for testing the validity of the new rewrite lang%0A        # however, it's not self explained enough :/%0A%0A        from kivy.lang import Builder%0A        from kivy.uix.widget import Widget%0A        from kivy.factory import Factory%0A        from kivy.properties import StringProperty, ObjectProperty, BooleanProperty%0A%0A        Builder.load_string(rules)%0A%0A        class TestWidget(Widget):%0A            source = StringProperty('')%0A            source2 = StringProperty('')%0A            source3 = StringProperty('')%0A            can_edit = BooleanProperty(False)%0A%0A            def __init__(self, **kwargs):%0A                self.register_event_type('on_release')%0A                super(TestWidget, self).__init__(**kwargs)%0A%0A            def on_release(self):%0A                pass%0A%0A        class MainWidget(Widget):%0A            refwid = ObjectProperty(None)%0A            refwid2 = ObjectProperty(None)%0A%0A        class TestWidget2(Widget):%0A            pass%0A%0A        Factory.register('TestWidget', cls=TestWidget)%0A        Factory.register('TestWidget2', cls=TestWidget2)%0A%0A        a = MainWidget()%0A        self.assertTrue(isinstance(a.refwid, TestWidget))%0A        self.assertEquals(a.refwid.source, 'valid.png')%0A        self.assertEquals(a.refwid.source2, 'valid.png')%0A        self.assertEquals(a.refwid.source3, 'valid.png')%0A        self.assertTrue(len(a.refwid.children) == 1)%0A        self.assertEquals(a.refwid.children%5B0%5D.title, 'valid')%0A        self.assertTrue(isinstance(a.refwid2, TestWidget2))%0A        self.assertEquals(a.refwid2.source, 'valid.png')%0A%0A

add unit test