示例#1
0
 def test_validate(self):
     v = IncreasingNumbersListValidator()
     self.assertEqual(v.validate("", 0), (v.Acceptable, '', 0))
     self.assertEqual(v.validate("1", 1), (v.Acceptable, '1', 1))
     self.assertEqual(v.validate(",", 0), (v.Acceptable, ',', 0))
     self.assertEqual(v.validate("-", 0), (v.Intermediate, '-', 0))
     self.assertEqual(v.validate("1,,", 1), (v.Acceptable, '1,,', 1))
     self.assertEqual(v.validate("1,a,", 1), (v.Invalid, '1,a,', 1))
     self.assertEqual(v.validate("a", 1), (v.Invalid, 'a', 1))
     self.assertEqual(v.validate("1,1", 0), (v.Intermediate, '1,1', 0))
     self.assertEqual(v.validate("1,12", 0), (v.Acceptable, '1,12', 0))
示例#2
0
 def test_fixup(self):
     v = IncreasingNumbersListValidator()
     self.assertEqual(v.fixup(""), "")
     self.assertEqual(v.fixup("1,,2"), "1, 2")
     self.assertEqual(v.fixup("1,,"), "1")
     self.assertEqual(v.fixup("1,"), "1")
     self.assertEqual(v.fixup(",1"), "1")
     self.assertEqual(v.fixup(","), "")