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 )
def test_format(self): assert NumberChoiceType.format(2, [(1, "A"), (2, "B"), (3, "C")]) == "B"
def test_validate(self): assert NumberChoiceType.parse("equals", "B", self.choices) == (2, None) assert NumberChoiceType.parse("equals", "X", self.choices) == (None, ANY(str))
def test_bad_value(self): assert NumberChoiceType.get_formatter(self.choices)(6) == 6
def test_format(self): assert NumberChoiceType.get_formatter(self.choices)(2) == "B" assert NumberChoiceType.get_formatter(self.choices)(None) is None