|
| 1 | +import pytest |
| 2 | + |
| 3 | +from .base import BaseTutorialLesson |
| 4 | + |
| 5 | + |
| 6 | +class TestBasicTypes(BaseTutorialLesson): |
| 7 | + def test_00_cli_valid_int_option(self): |
| 8 | + result = self.run_command(["--int-option", "42"]) |
| 9 | + assert "int: 42\n" in result.output |
| 10 | + |
| 11 | + def test_01_cli_invalid_int_option(self): |
| 12 | + result = self.run_command(["--int-option", "3.14"]) |
| 13 | + assert "Invalid value" in result.output |
| 14 | + assert result.exit_code == 2 |
| 15 | + |
| 16 | + def test_02_cli_valid_float_option(self): |
| 17 | + result = self.run_command(["--float-option", "3.14"]) |
| 18 | + assert "float: 3.14\n" in result.output |
| 19 | + |
| 20 | + def test_03_cli_invalid_float_option(self): |
| 21 | + result = self.run_command(["--float-option", "abcd"]) |
| 22 | + assert "Invalid value" in result.output |
| 23 | + assert result.exit_code == 2 |
| 24 | + |
| 25 | + def test_04_cli_valid_bool_option(self): |
| 26 | + result = self.run_command(["--bool-option", "True"]) |
| 27 | + assert "bool: True\n" in result.output |
| 28 | + |
| 29 | + def test_05_cli_invalid_bool_option(self): |
| 30 | + result = self.run_command(["--bool-option", "3.14"]) |
| 31 | + assert "Invalid value" in result.output |
| 32 | + assert result.exit_code == 2 |
| 33 | + |
| 34 | + @pytest.mark.parametrize("test_input", ["A", "B", "C"]) |
| 35 | + def test_06_cli_valid_choice_option(self, test_input): |
| 36 | + result = self.run_command(["--choice-option", test_input]) |
| 37 | + assert "choice: {}\n".format(test_input) in result.output |
| 38 | + |
| 39 | + def test_07_cli_invalid_choice_option(self): |
| 40 | + result = self.run_command(["--choice-option", "1"]) |
| 41 | + assert "Invalid value" in result.output |
| 42 | + assert result.exit_code == 2 |
0 commit comments