Skip to content

Commit 3343a19

Browse files
committed
Remove now-unused subprocess.run mock
1 parent d4fe333 commit 3343a19

1 file changed

Lines changed: 2 additions & 34 deletions

File tree

tests/test_manage_cookie.py

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
import os
33
import subprocess
44
import sys
5-
import textwrap
65
from pathlib import Path
76
from types import SimpleNamespace
8-
from typing import Any, Dict, Iterable, Iterator, Tuple
7+
from typing import Iterable, Iterator
98
from unittest.mock import MagicMock, patch
109

1110
import github
@@ -95,26 +94,6 @@ def new_cookie_with_lock(new_cookie: Path, temp_dir: str) -> Iterator[Path]:
9594
yield new_cookie
9695

9796

98-
@pytest.fixture
99-
def run_or_mock() -> Iterator[Dict[Tuple[str, ...], str]]:
100-
real_run = subprocess.run
101-
mocked_commands: Dict[Tuple[str, ...], str] = {}
102-
103-
def _run(*args: Any, **kwargs: Any) -> Any:
104-
cmd = args[0]
105-
cmd_tuple = tuple(cmd)
106-
while cmd_tuple:
107-
if cmd_tuple in mocked_commands:
108-
return SimpleNamespace(
109-
stdout=mocked_commands[cmd_tuple].encode()
110-
)
111-
cmd_tuple = cmd_tuple[:-1]
112-
return real_run(*args, **kwargs)
113-
114-
with patch.object(subprocess, "run", _run):
115-
yield mocked_commands
116-
117-
11897
def _manage_cookie(argv: Iterable[str]) -> None:
11998
with patch.object(sys, "argv", argv):
12099
manage_cookie_main()
@@ -133,18 +112,7 @@ def test_manage_cookie_update(new_cookie_with_lock: str) -> None:
133112

134113

135114
@pytest.mark.parametrize("add_commit", (True, False))
136-
def test_manage_cookie_release(
137-
new_cookie: str, run_or_mock: Dict[Tuple[str, ...], str], add_commit: bool
138-
) -> None:
139-
run_or_mock[("gh", "release", "list")] = textwrap.dedent(
140-
"""
141-
TITLE TYPE TAG NAME PUBLISHED
142-
v1.1.38 Latest v1.1.38 in a galaxy far, far away
143-
v0.21.87 v0.21.87 about a long time ago
144-
v0.0.1 v0.0.1 about never ago
145-
"""
146-
).strip()
147-
run_or_mock[("gh",)] = "" # Prevent any actual gh invocations
115+
def test_manage_cookie_release(new_cookie: str, add_commit: bool) -> None:
148116
subprocess.run(["git", "tag", "v1.1.38", "@"], cwd=new_cookie, check=True)
149117
if add_commit:
150118
subprocess.run(

0 commit comments

Comments
 (0)