diff --git a/tests/conftest.py b/tests/conftest.py index e1b39f45a..5e18e5ca6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -11,6 +11,9 @@ # Make tests more predictable and avoid loading real configs in tests. os.environ["XDG_CONFIG_HOME"] = str(Path(__file__).parent / "data/user_dirs/config") os.environ["XDG_DATA_HOME"] = str(Path(__file__).parent / "data/user_dirs/data") +# Windows does not use the *nix environment variables XDG_CONFIG_HOME and XDG_DATA_HOME +# It has only one corresponding folder for both config and data: APPDATA +os.environ["APPDATA"] = str(Path(__file__).parent / "data/user_dirs/AppData/Roaming") @pytest.fixture diff --git a/tests/data/user_dirs/AppData/Roaming/openeo-python-client/.gitignore b/tests/data/user_dirs/AppData/Roaming/openeo-python-client/.gitignore new file mode 100644 index 000000000..f59ec20aa --- /dev/null +++ b/tests/data/user_dirs/AppData/Roaming/openeo-python-client/.gitignore @@ -0,0 +1 @@ +* \ No newline at end of file diff --git a/tests/test_config.py b/tests/test_config.py index 33fd462b8..e2ce2481c 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -16,23 +16,19 @@ def test_get_user_config_dir(): - # 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 / "data/user_dirs/config") - assert get_user_config_dir() == Path(__file__).parent / "data/user_dirs/config/openeo-python-client" + expected = Path(__file__).parent / "data/user_dirs/AppData/Roaming/openeo-python-client" + else: + expected = Path(__file__).parent / "data/user_dirs/config/openeo-python-client" + assert get_user_config_dir() == expected def test_get_user_data_dir(): - # 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 / "data/user_dirs/data") - assert get_user_data_dir() == Path(__file__).parent / "data/user_dirs/data/openeo-python-client" + expected = Path(__file__).parent / "data/user_dirs/AppData/Roaming/openeo-python-client" + else: + expected = Path(__file__).parent / "data/user_dirs/data/openeo-python-client" + assert get_user_data_dir() == expected class TestClientConfig: