From 965aa6608702d4ae2231e33930860d9f3ebf3ec3 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 28 Aug 2022 14:27:17 -0500 Subject: [PATCH] test(test_tmux_cmd_raises_on_not_found): Use monkeypatch --- tests/test_common.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tests/test_common.py b/tests/test_common.py index 34e3335b7..14c5c39a5 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -2,7 +2,6 @@ import re import sys -import os import typing as t from distutils.version import LooseVersion from typing import Optional @@ -24,7 +23,7 @@ has_minimum_version, has_version, session_check_name, - tmux_cmd + tmux_cmd, ) from libtmux.exc import BadSessionName, LibTmuxException, TmuxCommandNotFound from libtmux.session import Session @@ -174,16 +173,11 @@ def test_has_lte_version() -> None: assert not has_lte_version("1.7b") -def test_tmux_cmd_raises_on_not_found() -> None: - previous_path = os.environ["PATH"] - os.environ["PATH"] = "" +def test_tmux_cmd_raises_on_not_found(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setenv("PATH", "") with pytest.raises(TmuxCommandNotFound): tmux_cmd("-V") - os.environ["PATH"] = previous_path - - tmux_cmd("-V") - def test_tmux_cmd_unicode(session: Session) -> None: session.cmd("new-window", "-t", 3, "-n", "юникод", "-F", "Ελληνικά")