diff --git a/tests/rest/auth/test_cli.py b/tests/rest/auth/test_cli.py index a678c3af6..3e774b4dc 100644 --- a/tests/rest/auth/test_cli.py +++ b/tests/rest/auth/test_cli.py @@ -1,5 +1,6 @@ import logging from unittest import mock +import os import pytest @@ -37,8 +38,8 @@ def refresh_token_store(tmp_openeo_config_home) -> RefreshTokenStore: def test_paths(capsys): cli.main(["paths"]) out = capsys.readouterr().out - assert "/auth-config.json" in out - assert "/refresh-tokens.json" in out + assert os.sep + "auth-config.json" in out + assert os.sep + "refresh-tokens.json" in out def test_config_dump(capsys, auth_config): diff --git a/tests/test_config.py b/tests/test_config.py index 868002ce3..73142049a 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,6 +1,7 @@ import contextlib import logging import os +import platform import random import re import textwrap @@ -15,11 +16,23 @@ def test_get_user_config_dir(): - assert get_user_config_dir() == Path(__file__).parent / "data/user_dirs/config/openeo-python-client" + # For Linux/Mac we configure the config and data directories in conftest.py + # via the environment variables XDG_CONFIG_HOME and XDG_DATA_HOME. + # But on Windows we need to set APPDATA instead, and we don't have separate + # variables for config and data. + if platform.system() == "Windows": + os.environ["APPDATA"] = str(Path(__file__).parent / Path("data/user_dirs/config")) + assert get_user_config_dir() == Path(__file__).parent / Path("data/user_dirs/config/openeo-python-client") def test_get_user_data_dir(): - assert get_user_data_dir() == Path(__file__).parent / "data/user_dirs/data/openeo-python-client" + # For Linux/Mac we configure the config and data directories in conftest.py + # via the environment variables XDG_CONFIG_HOME and XDG_DATA_HOME. + # But on Windows we need to set APPDATA instead, and we don't have separate + # variables for config and data. + if platform.system() == "Windows": + os.environ["APPDATA"] = str(Path(__file__).parent / Path("data/user_dirs/data")) + assert get_user_data_dir() == Path(__file__).parent / Path("data/user_dirs/data/openeo-python-client") class TestClientConfig: