Skip to content

Commit e3fbfa0

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

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

tests/test_common.py

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""Tests for utility functions in libtmux."""
22

3+
import os
34
import re
45
import sys
5-
import os
66
import typing as t
77
from distutils.version import LooseVersion
88
from typing import Optional
@@ -24,7 +24,7 @@
2424
has_minimum_version,
2525
has_version,
2626
session_check_name,
27-
tmux_cmd
27+
tmux_cmd,
2828
)
2929
from libtmux.exc import BadSessionName, LibTmuxException, TmuxCommandNotFound
3030
from libtmux.session import Session
@@ -174,16 +174,11 @@ def test_has_lte_version() -> None:
174174
assert not has_lte_version("1.7b")
175175

176176

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

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

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

0 commit comments

Comments
 (0)