示例#1
0
 def test_ptk_prompt_initialization(self, ptk_prompt: Mock) -> None:
     number_range = input_types.NumberRange(1, 5)
     assert number_range.raw_prompt("Enter number") == "3"
     ptk_prompt.assert_called_once_with("Enter number: ",
                                        completer=None,
                                        validator=ANY)
示例#2
0
 def test_prompt_response_cast_to_int(self, ptk_prompt: Mock) -> None:
     number_range = input_types.NumberRange(1, 5)
     assert number_range.prompt("Enter number") == 3
示例#3
0
 def test_validator(self) -> None:
     assert isinstance(input_types.NumberRange(1, 5).validator, Validator)
示例#4
0
 def test_cast(self) -> None:
     assert input_types.NumberRange(1, 5).cast("3") == 3
示例#5
0
 def test_non_number_is_not_valid(self) -> None:
     assert input_types.NumberRange(1, 5).is_valid("bad") is False
示例#6
0
 def test_above_range_is_not_valid(self) -> None:
     assert input_types.NumberRange(1, 5).is_valid("6") is False
示例#7
0
 def test_inclusive_range_is_valid(self) -> None:
     number_range = input_types.NumberRange(1, 5)
     assert number_range.is_valid("1") is True
     assert number_range.is_valid("5") is True