def iteration(options):
raw = {'<STR_LIT:foo>': '<STR_LIT:bar>', '<STR_LIT>': '<STR_LIT>', '<STR_LIT>': '<STR_LIT>'}<EOL>mapping = options.constructor(raw)<EOL>expected_keys = frozenset(('<STR_LIT:foo>', '<STR_LIT>', '<STR_LIT>'))<EOL>expected_values = frozenset(('<STR_LIT:bar>', '<STR_LIT>', '<STR_LIT>'))<EOL>expected_items = frozenset(<EOL>(('<STR_LIT:foo>', '<STR_LIT:bar>'), ('<STR_LIT>', '<STR_LIT>'), ('<STR_LIT>', '<STR_LIT>'))<EOL>)<EOL>assert_equals(set(iter(mapping)), expected_keys)<EOL>actual_keys = mapping.keys()<EOL>actual_values = mapping.values()<EOL>actual_items = mapping.items()<EOL>if six.PY2:<EOL><INDENT>for collection in (actual_keys, actual_values, actual_items):<EOL><INDENT>assert_true(isinstance(collection, list))<EOL><DEDENT>assert_equals(frozenset(actual_keys), expected_keys)<EOL>assert_equals(frozenset(actual_values), expected_values)<EOL>assert_equals(frozenset(actual_items), expected_items)<EOL>if options.iter_methods:<EOL><INDENT>actual_keys = mapping.iterkeys()<EOL>actual_values = mapping.itervalues()<EOL>actual_items = mapping.iteritems()<EOL>for iterable in (actual_keys, actual_values, actual_items):<EOL><INDENT>assert_false(isinstance(iterable, list))<EOL><DEDENT>assert_equals(frozenset(actual_keys), expected_keys)<EOL>assert_equals(frozenset(actual_values), expected_values)<EOL>assert_equals(frozenset(actual_items), expected_items)<EOL><DEDENT>if options.view_methods:<EOL><INDENT>actual_keys = mapping.viewkeys()<EOL>actual_values = mapping.viewvalues()<EOL>actual_items = mapping.viewitems()<EOL>for iterable in (actual_keys, actual_values, actual_items):<EOL><INDENT>assert_false(isinstance(iterable, list))<EOL><DEDENT>assert_equals(frozenset(actual_keys), expected_keys)<EOL>assert_equals(frozenset(actual_values), expected_values)<EOL>assert_equals(frozenset(actual_items), expected_items)<EOL>from attrdict.mapping import AttrMap<EOL>mapping = options.constructor(AttrMap(raw))<EOL>actual_keys = mapping.viewkeys()<EOL>actual_values = mapping.viewvalues()<EOL>actual_items = mapping.viewitems()<EOL>for iterable in (actual_keys, actual_values, actual_items):<EOL><INDENT>assert_false(isinstance(iterable, list))<EOL><DEDENT>assert_equals(frozenset(actual_keys), expected_keys)<EOL>assert_equals(frozenset(actual_values), expected_values)<EOL>assert_equals(frozenset(actual_items), expected_items)<EOL><DEDENT><DEDENT>else:  <EOL><INDENT>assert_true(isinstance(actual_keys, KeysView))<EOL>assert_equals(frozenset(actual_keys), expected_keys)<EOL>assert_true(isinstance(actual_values, ValuesView))<EOL>assert_equals(frozenset(actual_values), expected_values)<EOL>assert_true(isinstance(actual_items, ItemsView))<EOL>assert_equals(frozenset(actual_items), expected_items)<EOL><DEDENT>assert_equals(tuple(options.constructor().items()), ())<EOL>
Iterate over keys/values/items in {cls}