def test_bad_value(self):
     assert NumberChoiceType.get_formatter([(1, "A"), (2, "B"), (3, "C")])(6) == 6
 def test_format(self):
     assert NumberChoiceType.get_formatter([(1, "A"), (2, "B"), (3, "C")])(2) == "B"
     assert (
         NumberChoiceType.get_formatter([(1, "A"), (2, "B"), (3, "C")])(None) is None
     )
示例#3
0
 def test_format(self):
     assert NumberChoiceType.format(2, [(1, "A"), (2, "B"), (3, "C")]) == "B"
示例#4
0
 def test_validate(self):
     assert NumberChoiceType.parse("equals", "B", self.choices) == (2, None)
     assert NumberChoiceType.parse("equals", "X",
                                   self.choices) == (None, ANY(str))
示例#5
0
 def test_bad_value(self):
     assert NumberChoiceType.get_formatter(self.choices)(6) == 6
示例#6
0
 def test_format(self):
     assert NumberChoiceType.get_formatter(self.choices)(2) == "B"
     assert NumberChoiceType.get_formatter(self.choices)(None) is None