Skip to content

Commit cd1eb20

Browse files
committed
use mocker instead of monkeypatch
1 parent fe89f35 commit cd1eb20

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tests/test_packsmanager.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ def test_copy_examples_force(example_cases, expected_paths, force):
372372

373373
@pytest.mark.parametrize("packs_to_install,expected", install_params)
374374
def test_print_packs_and_examples(
375-
packs_to_install, expected, example_cases, capsys, monkeypatch
375+
packs_to_install, expected, example_cases, capsys, mocker
376376
):
377377
case5dir = example_cases / "case5"
378378
req_dir = case5dir / "requirements" / "packs"
@@ -382,13 +382,15 @@ def test_print_packs_and_examples(
382382
req_file = req_dir / f"{pack}.txt"
383383
for line in req_file.read_text().splitlines():
384384
line = line.strip()
385-
installed_reqs.append(line)
385+
if line and not line.startswith("#"):
386+
installed_reqs.append(line)
386387

387388
def mock_is_installed(name: str) -> bool:
388389
return name in installed_reqs
389390

390-
monkeypatch.setattr(installer, "_is_installed", mock_is_installed)
391-
391+
mocker.patch.object(
392+
installer, "_is_installed", side_effect=mock_is_installed
393+
)
392394
pm = PacksManager(root_path=case5dir)
393395
pm.print_packs()
394396
pm.print_examples()

0 commit comments

Comments
 (0)