예제 #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_has_correct_name(self):
     space_name = "tomato"
     space = Space(name=space_name, outer_space={})
     assert space.name == space_name
예제 #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_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
예제 #9
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
예제 #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_representation(self):
     space = Space(name='tomato', outer_space={})
     space.namespace['x'] = 1
     space.namespace['y'] = 1
     assert repr(space) == 'Space(name=tomato, size=2)'
예제 #12
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
예제 #13
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
예제 #14
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
예제 #15
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
예제 #16
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
예제 #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
예제 #18
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]
예제 #19
0
 def test_space_representation(self):
     space = Space(name="tomato", outer_space={})
     space.namespace["x"] = 1
     space.namespace["y"] = 1
     assert repr(space) == "Space(name=tomato, size=2)"
예제 #20
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