forked from tylerdave/PyTN2016-Click-Tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_types.py
More file actions
32 lines (24 loc) · 1.12 KB
/
basic_types.py
File metadata and controls
32 lines (24 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python
from .base import BaseTutorialLesson
class TestBasicTypes(BaseTutorialLesson):
def test_00_cli_valid_int_option(self):
result = self.run_command(['--int-option', '42'])
assert "int: 42\n" in result.output
def test_01_cli_invalid_int_option(self):
result = self.run_command(['--int-option', '3.14'])
assert "Invalid value" in result.output
assert result.exit_code == 2
def test_02_cli_valid_float_option(self):
result = self.run_command(['--float-option', '3.14'])
assert "float: 3.14\n" in result.output
def test_03_cli_invalid_float_option(self):
result = self.run_command(['--float-option', 'abcd'])
assert "Invalid value" in result.output
assert result.exit_code == 2
def test_04_cli_valid_bool_option(self):
result = self.run_command(['--bool-option', 'True'])
assert "bool: True\n" in result.output
def test_05_cli_invalid_bool_option(self):
result = self.run_command(['--bool-option', '3.14'])
assert "Invalid value" in result.output
assert result.exit_code == 2