<s> import unittest <EOL> from test import test_support <EOL> from test_userdict import TestMappingProtocol <EOL> from org . python . core import PyStringMap <EOL> class SimpleClass : <EOL> pass <EOL> class StringMapTest ( TestMappingProtocol ) : <EOL> _tested_class = None <EOL> class ClassDictTests ( StringMapTest ) : <EOL> """<STR_LIT>""" <EOL> def _empty_mapping ( self ) : <EOL> for key in SimpleClass . __dict__ . copy ( ) : <EOL> SimpleClass . __dict__ . pop ( key ) <EOL> return SimpleClass . __dict__ <EOL> class InstanceDictTests ( StringMapTest ) : <EOL> def _empty_mapping ( self ) : <EOL> return SimpleClass ( ) . __dict__ <EOL> class PyStringMapTest ( StringMapTest ) : <EOL> _tested_class = PyStringMap <EOL> def test_all ( self ) : <EOL> d = PyStringMap ( ) <EOL> d [ "<STR_LIT>" ] = <NUM_LIT:1> <EOL> self . assertEqual ( d [ "<STR_LIT>" ] , <NUM_LIT:1> ) <EOL> self . assertRaises ( KeyError , d . __getitem__ , "<STR_LIT>" ) <EOL> del d [ "<STR_LIT>" ] <EOL> self . assertRaises ( KeyError , d . __delitem__ , "<STR_LIT>" ) <EOL> d . update ( self . _reference ( ) ) <EOL> d . clear ( ) <EOL> self . assertEqual ( d , { } ) <EOL> d . update ( self . _reference ( ) ) <EOL> da = d . copy ( ) <EOL> self . assertEqual ( d , da ) <EOL> r = self . _reference ( ) <EOL> d . update ( self . _reference ( ) ) <EOL> for k in d . keys ( ) : <EOL> self . failUnless ( k in r . keys ( ) ) <EOL> for i in d . items ( ) : <EOL> self . failUnless ( i in r . items ( ) ) <EOL> for v in d . values ( ) : <EOL> self . failUnless ( v in r . values ( ) ) <EOL> for i in r . keys ( ) : <EOL> self . assert_ ( d . has_key ( i ) ) <EOL> self . assert_ ( i in d ) <EOL> def test_stringmap_in_mapping ( self ) : <EOL> class A : <EOL> def __init__ ( self ) : <EOL> self . a = "<STR_LIT:a>" <EOL> self . assertEquals ( "<STR_LIT:a>" , "<STR_LIT>" % A ( ) . __dict__ ) <EOL> def test_main ( ) : <EOL> test_support . run_unittest ( <EOL> ClassDictTests , <EOL> InstanceDictTests , <EOL> PyStringMapTest <EOL> ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test_main ( ) </s>
