示例#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
示例#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
示例#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
示例#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
示例#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
示例#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
示例#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
示例#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]
示例#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
示例#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")
示例#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
示例#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
示例#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
示例#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
示例#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
示例#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
示例#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