Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #2430: test_cases.diff

File test_cases.diff, 1.2 KB (added by xaka, 2 years ago)
  • turbogears/widgets/tests/test_widgets.py

     
    773773    assert w1.attrs == {'test':True} 
    774774    assert w2.attrs == {} 
    775775 
     776def test_lazy_param_initialization(): 
     777    touched = False 
     778    class Widget(widgets.Widget): 
     779        params = ['test'] 
     780        def test(self): 
     781            global touched 
     782            touched = True 
     783    w = Widget() 
     784    assert not touched, 'Widget.test param must not be touched automatically!' 
     785 
     786def test_param_without_declaration(): 
     787    class Widget(widgets.Widget): 
     788            params = ['test'] 
     789    w = Widget() 
     790    assert w.test is None, 'w.test must be None' 
     791 
     792    class Widget(widgets.Widget): 
     793            params = ['test'] 
     794    w = Widget(test=lambda:1) 
     795    assert w.test == 1, '%s != %s' % (w.test, 1) 
     796 
     797    class Widget(widgets.Widget): 
     798            params = ['test'] 
     799    w = Widget() 
     800    w.test = lambda:1 
     801    assert w.test == 1, '%s != %s' % (w.test, 1) 
     802 
    776803def test_param_descriptor_properties(): 
    777804    class Wid(widgets.Widget): 
    778805        params = ['attrs']