<s> from metakernel import Magic , option <EOL> from metakernel . tests . utils import get_kernel , get_log_text <EOL> class Dummy ( Magic ) : <EOL> @ option ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store>' , <EOL> help = '<STR_LIT>' <EOL> ) <EOL> def line_dummy ( self , foo , size = None ) : <EOL> """<STR_LIT>""" <EOL> self . foo = foo <EOL> self . size = size <EOL> def cell_spam ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def line_eggs ( self , style ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def test_get_magics ( ) : <EOL> kernel = get_kernel ( ) <EOL> d = Dummy ( kernel ) <EOL> line = d . get_magics ( '<STR_LIT>' ) <EOL> cell = d . get_magics ( '<STR_LIT>' ) <EOL> assert '<STR_LIT>' in line <EOL> assert '<STR_LIT>' in cell <EOL> assert '<STR_LIT>' in line <EOL> def test_get_help ( ) : <EOL> kernel = get_kernel ( ) <EOL> d = Dummy ( kernel ) <EOL> dummy_help = d . get_help ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:0> ) <EOL> assert dummy_help . startswith ( "<STR_LIT>" ) <EOL> assert "<STR_LIT>" in d . line_dummy . __doc__ , "<STR_LIT>" <EOL> assert "<STR_LIT>" in dummy_help , "<STR_LIT>" <EOL> dummy_help = d . get_help ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> assert "<STR_LIT>" in dummy_help <EOL> spam_help = d . get_help ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:0> ) <EOL> assert spam_help . startswith ( "<STR_LIT>" ) , spam_help <EOL> spam_help = d . get_help ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> assert "<STR_LIT>" in spam_help <EOL> def test_option ( ) : <EOL> kernel = get_kernel ( ) <EOL> d = Dummy ( kernel ) <EOL> assert '<STR_LIT>' in d . line_dummy . __doc__ <EOL> assert '<STR_LIT>' in d . line_dummy . __doc__ <EOL> ret = d . call_magic ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> assert ret == d <EOL> assert d . foo == '<STR_LIT>' , d . foo <EOL> assert d . size == ( <NUM_LIT> , <NUM_LIT:200> ) <EOL> ret = d . call_magic ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> assert d . foo == '<STR_LIT>' <EOL> ret = d . call_magic ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> assert d . foo == range ( <NUM_LIT:1> , <NUM_LIT:10> ) <EOL> ret = d . call_magic ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> assert d . foo == [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] <EOL> ret = d . call_magic ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> assert d . size == ( <NUM_LIT> , <NUM_LIT:200> ) <EOL> assert d . foo == "<STR_LIT>" <EOL> ret = d . call_magic ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> assert d . size == ( <NUM_LIT> , <NUM_LIT:200> ) <EOL> assert d . foo == "<STR_LIT>" </s>
