Skip to content

Commit e379234

Browse files
committed
test(assert_complete): support "shopt" arg
1 parent 864f7f4 commit e379234

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

test/t/conftest.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@
99
import time
1010
from pathlib import Path
1111
from types import TracebackType
12-
from typing import Callable, Iterable, Iterator, List, Optional, Tuple, Type
12+
from typing import (
13+
Callable,
14+
Dict,
15+
Iterable,
16+
Iterator,
17+
List,
18+
Optional,
19+
Tuple,
20+
Type,
21+
)
1322

1423
import pexpect # type: ignore[import]
1524
import pytest
@@ -389,7 +398,6 @@ def assert_bash_exec(
389398

390399

391400
class bash_env_saved:
392-
393401
def __init__(self, bash: pexpect.spawn, sendintr: bool = False):
394402
self.bash = bash
395403
self.cwd: Optional[str] = None
@@ -609,6 +617,9 @@ def assert_complete(
609617
for k, v in kwargs.get("env", {}).items():
610618
bash_env.write_env(k, v)
611619

620+
for k, v in kwargs.get("shopt", {}).items():
621+
bash_env.shopt(k, v)
622+
612623
bash.send(cmd + "\t")
613624
# Sleep a bit if requested, to avoid `.*` matching too early
614625
time.sleep(kwargs.get("sleep_after_tab", 0))

test/t/test_man.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,10 @@ def test_8(self, completion):
100100
"man %s" % assumed_present,
101101
require_cmd=True,
102102
cwd="shared/empty_dir",
103-
pre_cmds=("shopt -s failglob",),
103+
shopt=dict(failglob=True),
104104
)
105105
def test_9(self, bash, completion):
106106
assert self.assumed_present in completion
107-
assert_bash_exec(bash, "shopt -u failglob")
108107

109108
@pytest.mark.complete(require_cmd=True)
110109
def test_10(self, request, bash, colonpath):

test/t/test_tar.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ def gnu_tar(self, bash):
1313
if not re.search(r"\bGNU ", got):
1414
pytest.skip("Not GNU tar")
1515

16-
@pytest.mark.complete("tar ", pre_cmds=("shopt -s failglob",))
16+
@pytest.mark.complete("tar ", shopt=dict(failglob=True))
1717
def test_1(self, bash, completion):
1818
assert completion
19-
assert_bash_exec(bash, "shopt -u failglob")
2019

2120
# Test "f" when mode is not as first option
2221
@pytest.mark.complete("tar zfc ", cwd="tar")

0 commit comments

Comments
 (0)