Skip to content

Commit a3ae40a

Browse files
committed
add integration tests for arguments
1 parent 1e8b4ba commit a3ae40a

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

tests/test_examples_integration.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class TestExample(unittest.TestCase):
1414
"""
1515
Run examples
1616
17-
prompt_toolkit behaves very differently when it is not connected to a real TTY.
17+
prompt_toolkit behaves differently when not connected to a real TTY.
1818
"""
1919

2020
def test_example_single_cmd(self):
@@ -79,6 +79,32 @@ def test_example_confirm_no(self):
7979
actual_output = result.stdout.splitlines()[-1]
8080
self.assertEqual("False", actual_output)
8181

82+
def test_example_argument(self):
83+
result = subprocess.run(
84+
[sys.executable, EXAMPLE_FILE, "argument"],
85+
input=f"{CURSOR_DOWN}\n",
86+
stdout=subprocess.PIPE,
87+
stderr=subprocess.PIPE,
88+
encoding="utf-8",
89+
)
90+
self.assertEqual(result.returncode, 0)
91+
expected_output = "Bananas"
92+
actual_output = result.stdout.splitlines()[-1]
93+
self.assertEqual(expected_output, actual_output)
94+
95+
def test_example_text_arg_prompt(self):
96+
result = subprocess.run(
97+
[sys.executable, EXAMPLE_FILE, "text-arg"],
98+
input="Test\n3\n",
99+
stdout=subprocess.PIPE,
100+
stderr=subprocess.PIPE,
101+
encoding="utf-8",
102+
)
103+
self.assertEqual(result.returncode, 0)
104+
expected_output = "Fruit: Test | Quantity: 3"
105+
actual_output = result.stdout.splitlines()[-1]
106+
self.assertEqual(expected_output, actual_output)
107+
82108
def test_file_path_prompt(self):
83109
result = subprocess.run(
84110
[sys.executable, EXAMPLE_FILE, "file"],

0 commit comments

Comments
 (0)