<s> from topaz . celldict import CellDict , Cell , GlobalsDict <EOL> from . base import BaseTopazTest <EOL> class TestCellDict ( BaseTopazTest ) : <EOL> def test_single_set ( self , space ) : <EOL> c = CellDict ( ) <EOL> v = c . version <EOL> c . set ( space , "<STR_LIT:a>" , <NUM_LIT:2> ) <EOL> assert c . version is not v <EOL> assert c . _get_cell ( "<STR_LIT:a>" , c . version ) == <NUM_LIT:2> <EOL> def test_multi_set ( self , space ) : <EOL> c = CellDict ( ) <EOL> c . set ( space , "<STR_LIT:a>" , <NUM_LIT:2> ) <EOL> v = c . version <EOL> c . set ( space , "<STR_LIT:a>" , <NUM_LIT:3> ) <EOL> assert isinstance ( c . _get_cell ( "<STR_LIT:a>" , c . version ) , Cell ) <EOL> assert c . version is not v <EOL> v = c . version <EOL> c . set ( space , "<STR_LIT:a>" , <NUM_LIT:4> ) <EOL> assert isinstance ( c . _get_cell ( "<STR_LIT:a>" , c . version ) , Cell ) <EOL> assert c . version is v <EOL> def test_globals ( self , space ) : <EOL> space . stuff = <NUM_LIT:4> <EOL> g = GlobalsDict ( ) <EOL> g . define_virtual ( "<STR_LIT:x>" , lambda s : s . stuff ) <EOL> assert g . get ( space , "<STR_LIT:x>" ) == <NUM_LIT:4> <EOL> with self . raises ( space , "<STR_LIT>" ) : <EOL> g . set ( space , "<STR_LIT:x>" , <NUM_LIT:5> ) <EOL> g . define_virtual ( "<STR_LIT:y>" , lambda s : s . stuff , lambda s , v : setattr ( s , "<STR_LIT>" , v ) ) <EOL> assert g . get ( space , "<STR_LIT:y>" ) == <NUM_LIT:4> <EOL> g . set ( space , "<STR_LIT:y>" , <NUM_LIT:5> ) <EOL> assert g . get ( space , "<STR_LIT:y>" ) == <NUM_LIT:5> </s>
