Skip to content

Commit 1c2c402

Browse files
committed
Fix tests in windows
1 parent 8cce8ea commit 1c2c402

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

jsonargparse_tests/test_parsing_settings.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import re
22
from dataclasses import dataclass
3-
from importlib.util import find_spec
43
from typing import Literal, Optional
54
from unittest.mock import patch
65

@@ -9,7 +8,6 @@
98
from jsonargparse import ActionYesNo, ArgumentError, Namespace, set_parsing_settings
109
from jsonargparse._common import get_parsing_setting
1110
from jsonargparse_tests.conftest import capture_logs, get_parse_args_stdout, get_parser_help
12-
from jsonargparse_tests.test_shtab import assert_bash_typehint_completions
1311
from jsonargparse_tests.test_typehints import Optimizer
1412

1513

@@ -154,24 +152,3 @@ def test_optionals_as_positionals_unsupported_arguments(parser):
154152

155153
help_str = get_parse_args_stdout(parser, ["--o1.help=Adam"])
156154
assert "extra positionals are parsed as optionals in the order shown above" not in help_str
157-
158-
159-
@pytest.mark.skipif(not find_spec("shtab"), reason="shtab package is required")
160-
def test_shtab_bash_optionals_as_positionals(parser, subtests):
161-
set_parsing_settings(parse_optionals_as_positionals=True)
162-
parser.prog = "tool"
163-
164-
parser.add_argument("job", type=str)
165-
parser.add_argument("--amount", type=int, default=0)
166-
parser.add_argument("--flag", type=bool, default=False)
167-
assert_bash_typehint_completions(
168-
subtests,
169-
parser,
170-
[
171-
("job", str, "", [], None),
172-
("job", str, "easy", [], None),
173-
("amount", int, "easy ", [], None),
174-
("amount", int, "easy 10", [], None),
175-
("flag", bool, "easy 10 x", [], "0/2"),
176-
],
177-
)

jsonargparse_tests/test_shtab.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import pytest
1212

13-
from jsonargparse import ArgumentParser
13+
from jsonargparse import ArgumentParser, set_parsing_settings
1414
from jsonargparse._completions import norm_name
1515
from jsonargparse._parameter_resolvers import get_signature_parameters
1616
from jsonargparse._typehints import type_to_str
@@ -196,6 +196,27 @@ def test_bash_positional(parser, subtests):
196196
)
197197

198198

199+
def test_shtab_bash_optionals_as_positionals(parser, subtests):
200+
with patch.dict("jsonargparse._common.parsing_settings"):
201+
set_parsing_settings(parse_optionals_as_positionals=True)
202+
parser.prog = "tool"
203+
204+
parser.add_argument("job", type=str)
205+
parser.add_argument("--amount", type=int, default=0)
206+
parser.add_argument("--flag", type=bool, default=False)
207+
assert_bash_typehint_completions(
208+
subtests,
209+
parser,
210+
[
211+
("job", str, "", [], None),
212+
("job", str, "easy", [], None),
213+
("amount", int, "easy ", [], None),
214+
("amount", int, "easy 10", [], None),
215+
("flag", bool, "easy 10 x", [], "0/2"),
216+
],
217+
)
218+
219+
199220
def test_bash_config(parser):
200221
parser.add_argument("--cfg", action="config")
201222
shtab_script = get_shtab_script(parser, "bash")

0 commit comments

Comments
 (0)