Skip to content

Commit

Permalink
use mock patches instead of environ replace
Browse files Browse the repository at this point in the history
  • Loading branch information
chadsr committed May 27, 2024
1 parent ad4ad51 commit c3a735b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tests/test_waybar_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,19 @@ def quotes_latest() -> ResponseQuotesLatest:
}


@mock.patch.dict(os.environ, {XDG_CONFIG_HOME_ENV: ""})
def test_parse_args_default_path():
with mock.patch("sys.argv", ["waybar_crypto.py"]):
os.environ[XDG_CONFIG_HOME_ENV] = ""
args = parse_args()
assert "config_path" in args
assert os.path.expanduser(DEFAULT_XDG_CONFIG_HOME_PATH) in os.path.expanduser(
args["config_path"]
)


@mock.patch.dict(os.environ, {XDG_CONFIG_HOME_ENV: TEST_CONFIG_PATH})
def test_parse_args_custom_xdg_data_home():
with mock.patch("sys.argv", ["waybar_crypto.py"]):
os.environ[XDG_CONFIG_HOME_ENV] = TEST_CONFIG_PATH
args = parse_args()
assert "config_path" in args
assert TEST_CONFIG_PATH in args["config_path"]
Expand Down Expand Up @@ -237,7 +237,6 @@ def test_read_config():
@mock.patch.dict(os.environ, {API_KEY_ENV: TEST_API_KEY})
def test_read_config_env():
config = read_config(TEST_CONFIG_PATH)

assert config["general"]["api_key"] == TEST_API_KEY


Expand Down

0 comments on commit c3a735b

Please sign in to comment.