Beispiel #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'})
Beispiel #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'})
def test_dictproperty_is_none():
    from kivy.properties import DictProperty

    d1 = DictProperty(None)
    d1.link(wid, 'd1')
    assert d1.get(wid) is None

    d2 = DictProperty({'a': 1, 'b': 2}, allownone=True)
    d2.link(wid, 'd2')
    d2.set(wid, None)
    assert d2.get(wid) is None
Beispiel #4
0
def test_dictproperty_is_none():
    from kivy.properties import DictProperty

    d1 = DictProperty(None)
    d1.link(wid, 'd1')
    assert d1.get(wid) is None

    d2 = DictProperty({'a': 1, 'b': 2}, allownone=True)
    d2.link(wid, 'd2')
    d2.set(wid, None)
    assert d2.get(wid) is None
Beispiel #5
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'})
Beispiel #6
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)
Beispiel #7
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)