示例#1
0
 def test_fails_on_inconsistent_length(self):
     try:
         fields.ConstantFieldFormat('inconsistent_length', False, '2', '"a"', _ANY_FORMAT)
         self.fail()
     except errors.InterfaceError as anticipated_error:
         dev_test.assert_error_fnmatches(
             self, anticipated_error, "length is 2 but must be 1 to match constant 'a'")
示例#2
0
 def test_can_match_empty_constant(self):
     always_empty_format = fields.ConstantFieldFormat('constant', True, None, '', _ANY_FORMAT)
     self.assertEqual(always_empty_format.validated(''), '')
示例#3
0
 def test_can_match_constant_string(self):
     self._constant_format = fields.ConstantFieldFormat('constant', False, None, '"some"', _ANY_FORMAT)
     self.assertEqual(self._constant_format.validated('some'), 'some')
示例#4
0
 def test_can_match_constant_float(self):
     self._constant_format = fields.ConstantFieldFormat('constant', False, None, '3.1', _ANY_FORMAT)
     self.assertEqual(self._constant_format.validated('3.1'), '3.1')
示例#5
0
 def setUp(self):
     self._constant_format = fields.ConstantFieldFormat('constant', False, None, 'some', _ANY_FORMAT)