Example #1
0
 def test_space_references_can_be_deleted_directly(self):
     space = Space(name='tomato', outer_space={})
     space.execute(source='x = 99')
     del space.namespace['x']
     with raises(NameError):
         space.execute(source='x')
     assert 'x' not in space.namespace
Example #2
0
 def test_space_references_can_be_deleted_directly(self):
     space = Space(name="tomato", outer_space={})
     space.execute(source="x = 99")
     del space.namespace["x"]
     with raises(NameError):
         space.execute(source="x")
     assert "x" not in space.namespace
Example #3
0
 def test_space_references_can_be_deleted_indirectly(self):
     space = Space(name="tomato", outer_space={})
     space.execute(source="x = 99")
     space.execute(source="del x")
     assert "x" not in space.namespace
Example #4
0
 def test_space_references_can_be_altered_indirectly(self):
     space = Space(name="tomato", outer_space={})
     space.execute(source="x = 99")
     space.execute(source="x = 101")
     space.execute(source="assert x == 101")
     assert space.namespace["x"] == 101
Example #5
0
 def test_space_references_prioritized_over_user_namespace_directly(self):
     outer_space = dict(x=100)
     space = Space(name="tomato", outer_space=outer_space)
     space.namespace["x"] = 99
     space.execute(source="assert x == 99")
     assert space.namespace["x"] == 99
Example #6
0
 def test_space_cannot_add_user_namespace_references(self):
     outer_space = {}
     space = Space(name="tomato", outer_space=outer_space)
     space.execute(source="reference = 99")
     assert "x" not in outer_space
Example #7
0
 def test_space_cannot_remove_user_namespace_references(self):
     outer_space = dict(x=100)
     space = Space(name="tomato", outer_space=outer_space)
     with raises(NameError):
         space.execute(source="del x")
     assert outer_space["x"] == 100
Example #8
0
 def test_space_can_alter_user_namespace_mutable_references(self):
     outer_space = dict(x=[1, 2, 3])
     space = Space(name="tomato", outer_space=outer_space)
     space.execute(source="x[-1] = 10")
     assert outer_space["x"] == [1, 2, 10]
Example #9
0
 def test_space_cannot_add_user_namespace_references(self):
     outer_space = {}
     space = Space(name='tomato', outer_space=outer_space)
     space.execute(source='reference = 99')
     assert 'x' not in outer_space
Example #10
0
 def test_space_can_access_user_namespace_references(self):
     outer_space = dict(x=100)
     space = Space(name="tomato", outer_space=outer_space)
     space.execute(source="assert x == 100")
Example #11
0
 def test_space_references_can_be_added_directly(self):
     space = Space(name='tomato', outer_space={})
     reference_value = 101
     space.namespace['x'] = reference_value
     space.execute(source='assert x == 101')
     assert space.namespace['x'] == reference_value
Example #12
0
 def test_space_references_can_be_deleted_indirectly(self):
     space = Space(name='tomato', outer_space={})
     space.execute(source='x = 99')
     space.execute(source='del x')
     assert 'x' not in space.namespace
Example #13
0
 def test_space_references_can_be_altered_indirectly(self):
     space = Space(name='tomato', outer_space={})
     space.execute(source='x = 99')
     space.execute(source='x = 101')
     space.execute(source='assert x == 101')
     assert space.namespace['x'] == 101
Example #14
0
 def test_space_references_prioritized_over_user_namespace_indirectly(self):
     outer_space = dict(x=100)
     space = Space(name='tomato', outer_space=outer_space)
     space.execute(source='x = 99')
     space.execute(source='assert x == 99')
     assert space.namespace['x'] == 99
Example #15
0
 def test_space_cannot_alter_user_namespace_immutable_references(self):
     outer_space = dict(x=100)
     space = Space(name="tomato", outer_space=outer_space)
     space.execute(source="x = 99")
     assert outer_space["x"] == 100
Example #16
0
 def test_space_references_can_be_added_directly(self):
     space = Space(name="tomato", outer_space={})
     reference_value = 101
     space.namespace["x"] = reference_value
     space.execute(source="assert x == 101")
     assert space.namespace["x"] == reference_value
Example #17
0
 def test_space_cannot_alter_user_namespace_immutable_references(self):
     outer_space = dict(x=100)
     space = Space(name='tomato', outer_space=outer_space)
     space.execute(source='x = 99')
     assert outer_space['x'] == 100