Skip to content

Commit 965aa66

Browse files
committed
test(test_tmux_cmd_raises_on_not_found): Use monkeypatch
1 parent c0e1138 commit 965aa66

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

tests/test_common.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import re
44
import sys
5-
import os
65
import typing as t
76
from distutils.version import LooseVersion
87
from typing import Optional
@@ -24,7 +23,7 @@
2423
has_minimum_version,
2524
has_version,
2625
session_check_name,
27-
tmux_cmd
26+
tmux_cmd,
2827
)
2928
from libtmux.exc import BadSessionName, LibTmuxException, TmuxCommandNotFound
3029
from libtmux.session import Session
@@ -174,16 +173,11 @@ def test_has_lte_version() -> None:
174173
assert not has_lte_version("1.7b")
175174

176175

177-
def test_tmux_cmd_raises_on_not_found() -> None:
178-
previous_path = os.environ["PATH"]
179-
os.environ["PATH"] = ""
176+
def test_tmux_cmd_raises_on_not_found(monkeypatch: pytest.MonkeyPatch) -> None:
177+
monkeypatch.setenv("PATH", "")
180178
with pytest.raises(TmuxCommandNotFound):
181179
tmux_cmd("-V")
182180

183-
os.environ["PATH"] = previous_path
184-
185-
tmux_cmd("-V")
186-
187181

188182
def test_tmux_cmd_unicode(session: Session) -> None:
189183
session.cmd("new-window", "-t", 3, "-n", "юникод", "-F", "Ελληνικά")

0 commit comments

Comments
 (0)