Changeset 421

Show
Ignore:
Timestamp:
09/27/07 18:53:48 (1 year ago)
Author:
bjourne
Message:

Add tests for PixbufDrawCache.get_method()

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pygtkimageview/tests/test_module.py

    r417 r421  
    269269    assert callable(obj.draw) 
    270270     
     271 
     272def test_get_draw_method(): 
     273    ''' 
     274    Sanity test for the PixbufDrawCache.get_method() classmethod. 
     275    ''' 
     276    obj = gtkimageview.PixbufDrawCache() 
     277    assert hasattr(obj, 'get_method') 
     278    opts = gtkimageview.PixbufDrawOpts() 
     279    gtkimageview.PixbufDrawCache.get_method(opts, opts) 
     280 
     281def test_return_of_get_draw_method(): 
     282    ''' 
     283    Ensure that PixbufDrawCache.get_method() returns either 
     284    DRAW_METHOD_CONTAINS, DRAW_METHOD_SCALE or DRAW_METHOD_SCROLL. 
     285    ''' 
     286    obj = gtkimageview.PixbufDrawCache() 
     287    opts = gtkimageview.PixbufDrawOpts() 
     288    ret = obj.get_method(opts, opts) 
     289    assert ret in (gtkimageview.DRAW_METHOD_CONTAINS, 
     290                   gtkimageview.DRAW_METHOD_SCALE, 
     291                   gtkimageview.DRAW_METHOD_SCROLL) 
     292 
     293def test_type_error_for_draw_method(): 
     294    ''' 
     295    Ensure that TypeError is raised if PixbufDrawCache.get_method() is 
     296    called with an argument that is not a PixbufDrawOpts object. 
     297    ''' 
     298    arg_pairs = [(None, None), 
     299                 (gtkimageview.PixbufDrawOpts(), None), 
     300                 (None, gtkimageview.PixbufDrawOpts()), 
     301                 ("Hello", "Foo")] 
     302    for last_opts, new_opts in arg_pairs: 
     303        try: 
     304            gtkimageview.PixbufDrawCache.get_method(last_opts, new_opts) 
     305            assert False 
     306        except TypeError: 
     307            assert True