def test_dir(self): options = Breakfast() self.assertEqual({ 'from_dictionary', 'get_all_options', 'slices', 'style', 'view_as', 'display_data' }, { attr for attr in dir(options) if not attr.startswith('_') and attr != 'next' }) self.assertEqual({ 'from_dictionary', 'get_all_options', 'style', 'view_as', 'display_data' }, { attr for attr in dir(options.view_as(Eggs)) if not attr.startswith('_') and attr != 'next' })
def copy_attrs(source, to): for attr in dir(source): if attr.startswith('_'): continue if attr.startswith('func_'): continue to.__setattr__(attr, getattr(source, attr))