示例#1
0
 def test_input_attributes_cannot_become_outputs(self):
     f = Form()
     f.y = 3
     f.x = 1
     f._enter_output_mode()
     f.z = 2
     with self.assertRaises(TypeError):
         f.x = 4
示例#2
0
 def test_attributes_remember_their_order(self):
     f = Form()
     f.y = 3
     f.x = 1
     f._enter_output_mode()
     f.z = 2
     assert f._inputs == ['y', 'x']
     assert f._outputs == ['z']
示例#3
0
 def test_attributes_remember_their_values(self):
     f = Form()
     f.y = 3
     f.x = 1
     f.z = 2
     assert f.x == 1
     assert f.y == 3
     assert f.z == 2
示例#4
0
 def test_default_attributes_disappear_from_output(self):
     f = Form()
     f.x = 1
     f._enter_default_mode()
     f.x = -1
     f.y = -2
     f._enter_output_mode()
     f.z = -3
     assert f._inputs == ['x']
     assert f._outputs == ['z']
示例#5
0
 def test_attributes_are_only_listed_once(self):
     f = Form()
     f.y = 3
     f.x = 1
     f._enter_output_mode()
     f.z = 2
     f.w = 4
     f.w = 8
     f.z = 1
     assert f._inputs == ['y', 'x']
     assert f._outputs == ['z', 'w']
示例#6
0
 def test_attribute_assignment_is_ignored_in_default_mode(self):
     f = Form()
     f.x = 1
     f.A = Form()
     f.A.y = 2
     f._enter_default_mode()
     f.x = -1
     f.y = -2
     f.A.x = -3
     f.A.y = -4
     assert f.x == 1
     assert f.y == -2
     assert f.A.x == -3
     assert f.A.y == 2
示例#7
0
 def test_input_attributes_cannot_be_set_twice(self):
     f = Form()
     f.y = 3
     f.x = 1
     with self.assertRaises(TypeError):
         f.y = 5