def test_lookup_from_inner_env(): """The `extend` function returns a new environment extended with more bindings.""" env = Environment({"foo": 42}) env = env.extend({"bar": True}) assert_equals(42, env.lookup("foo")) assert_equals(True, env.lookup("bar"))
def test_extend_returns_new_environment(): """The extend method should create a new environment, leaving the old one unchanged.""" env = Environment({"foo": 1}) extended = env.extend({"foo": 2}) assert_equals(1, env.lookup("foo")) assert_equals(2, extended.lookup("foo"))