Ejemplo n.º 1
0
    def test_dictcheck(self):
        from kivy.properties import DictProperty

        a = DictProperty()
        a.link(wid, 'a')
        a.link_deps(wid, 'a')
        self.assertEqual(a.get(wid), {})
        a.set(wid, {'foo': 'bar'})
        self.assertEqual(a.get(wid), {'foo': 'bar'})
Ejemplo n.º 2
0
    def test_dictcheck(self):
        from kivy.properties import DictProperty

        a = DictProperty()
        a.link(wid, 'a')
        a.link_deps(wid, 'a')
        self.assertEqual(a.get(wid), {})
        a.set(wid, {'foo': 'bar'})
        self.assertEqual(a.get(wid), {'foo': 'bar'})
Ejemplo n.º 3
0
def test_dictcheck(self, set_name):
    from kivy.properties import DictProperty

    a = DictProperty()
    if set_name:
        a.set_name(wid, 'a')
        a.link_eagerly(wid)
    else:
        a.link(wid, 'a')
        a.link_deps(wid, 'a')
    self.assertEqual(a.get(wid), {})
    a.set(wid, {'foo': 'bar'})
    self.assertEqual(a.get(wid), {'foo': 'bar'})
Ejemplo n.º 4
0
def test_dict(self, set_name):
    from kivy.properties import DictProperty

    x = DictProperty()
    if set_name:
        x.set_name(wid, 'x')
        x.link_eagerly(wid)
    else:
        x.link(wid, 'x')
        x.link_deps(wid, 'x')

    # test observer
    global observe_called
    observe_called = 0

    def observe(obj, value):
        global observe_called
        observe_called = 1

    x.bind(wid, observe)

    observe_called = 0
    x.get(wid)['toto'] = 1
    self.assertEqual(observe_called, 1)

    observe_called = 0
    x.get(wid)['toto'] = 2
    self.assertEqual(observe_called, 1)

    observe_called = 0
    x.get(wid)['youupi'] = 2
    self.assertEqual(observe_called, 1)

    observe_called = 0
    del x.get(wid)['toto']
    self.assertEqual(observe_called, 1)

    observe_called = 0
    x.get(wid).update({'bleh': 5})
    self.assertEqual(observe_called, 1)
Ejemplo n.º 5
0
    def test_dict(self):
        from kivy.properties import DictProperty

        x = DictProperty()
        x.link(wid, 'x')
        x.link_deps(wid, 'x')

        # test observer
        global observe_called
        observe_called = 0

        def observe(obj, value):
            global observe_called
            observe_called = 1

        x.bind(wid, observe)

        observe_called = 0
        x.get(wid)['toto'] = 1
        self.assertEqual(observe_called, 1)

        observe_called = 0
        x.get(wid)['toto'] = 2
        self.assertEqual(observe_called, 1)

        observe_called = 0
        x.get(wid)['youupi'] = 2
        self.assertEqual(observe_called, 1)

        observe_called = 0
        del x.get(wid)['toto']
        self.assertEqual(observe_called, 1)

        observe_called = 0
        x.get(wid).update({'bleh': 5})
        self.assertEqual(observe_called, 1)