def test_getcache_and_builtins(self): space = FakeSpace() strategy = ModuleDictStrategy(space) storage = strategy.get_empty_storage() builtindict = W_ModuleDictObject(space, strategy, storage) builtindict.setitem_str("len", 2) builtindict.setitem_str("list", 19) class FakeModule: w_dict = builtindict space.builtin = FakeModule() storage = strategy.get_empty_storage() d = W_ModuleDictObject(space, strategy, storage) # just in the builtins c = d.get_global_cache("len") assert c.cell is None assert c.builtincache.cell == 2 # in both dicts d.setitem_str("list", 23) c = d.get_global_cache("list") assert c.cell == 23 assert c.builtincache is None # not in the builtins but in the normal dict d.setitem_str("a", 45) c = d.get_global_cache("a") assert c.cell == 45 assert c.builtincache is None # not in either dict c = d.get_global_cache("b") assert c.cell is None assert c.builtincache is None