Skip to content

Commit 959e6f9

Browse files
akinomyogascop
andcommitted
test(python): add tests for script arguments
Co-authored-by: Ville Skyttä <[email protected]>
1 parent 128640e commit 959e6f9

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

test/fixtures/python/bar.txt

Whitespace-only changes.

test/fixtures/python/foo.py

Whitespace-only changes.

test/t/test_python.py

+39
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,42 @@ def test_9(self, completion):
4545
)
4646
def test_bb(self, completion):
4747
assert "-bb" in completion
48+
49+
@pytest.mark.complete("python foo ", cwd="python")
50+
def test_script_arg(self, completion):
51+
assert "bar.txt" in completion
52+
53+
@pytest.mark.complete("python -- foo ", cwd="python")
54+
def test_script_arg_with_double_hyphen(self, completion):
55+
assert "bar.txt" in completion
56+
57+
@pytest.mark.complete("python -m foo bar -p ", cwd="python")
58+
def test_module_arg(self, completion):
59+
assert "bar.txt" in completion
60+
61+
@pytest.mark.complete("python foo bar -p ", cwd="python")
62+
def test_script_arg_after_option(self, completion):
63+
assert "bar.txt" in completion
64+
65+
@pytest.mark.complete("python -- foo bar -p ", cwd="python")
66+
def test_script_arg_after_option_with_double_hyphen(self, completion):
67+
assert "bar.txt" in completion
68+
69+
@pytest.mark.complete("python -m foo bar -p ", cwd="python")
70+
def test_module_arg_after_option(self, completion):
71+
assert "bar.txt" in completion
72+
73+
@pytest.mark.complete("python -mfoo bar -p ", cwd="python")
74+
def test_module_arg_after_option_with_connected_m_arg(self, completion):
75+
assert "bar.txt" in completion
76+
77+
@pytest.mark.complete("python -- ", cwd="python")
78+
def test_script_name(self, completion):
79+
assert "bar.txt" not in completion
80+
81+
@pytest.mark.complete("python -W -mfoo ", cwd="python")
82+
def test_script_name_with_fake_m_arg(self, completion):
83+
"""In this case, -mfoo looks like an option to specify the module, but
84+
it should not be treated as the module name because it is an option
85+
argument to -W."""
86+
assert "bar.txt" not in completion

0 commit comments

Comments
 (0)