Skip to content

Commit 85c0151

Browse files
#350 Simplify tests with better default env var: APPDATA
1 parent 737187f commit 85c0151

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

tests/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
# Make tests more predictable and avoid loading real configs in tests.
1212
os.environ["XDG_CONFIG_HOME"] = str(Path(__file__).parent / "data/user_dirs/config")
1313
os.environ["XDG_DATA_HOME"] = str(Path(__file__).parent / "data/user_dirs/data")
14+
# Windows does not use the *nix environment variables XDG_CONFIG_HOME and XDG_DATA_HOME
15+
# It has only one corresponding folder for both config and data: APPDATA
16+
os.environ["APPDATA"] = str(Path(__file__).parent / "data/user_dirs/AppData/Roaming")
1417

1518

1619
@pytest.fixture
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*

tests/test_config.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,19 @@
1616

1717

1818
def test_get_user_config_dir():
19-
# For Linux/Mac we configure the config and data directories in conftest.py
20-
# via the environment variables XDG_CONFIG_HOME and XDG_DATA_HOME.
21-
# But on Windows we need to set APPDATA instead, and we don't have separate
22-
# variables for config and data.
2319
if platform.system() == "Windows":
24-
os.environ["APPDATA"] = str(Path(__file__).parent / "data/user_dirs/config")
25-
assert get_user_config_dir() == Path(__file__).parent / "data/user_dirs/config/openeo-python-client"
20+
expected = Path(__file__).parent / "data/user_dirs/AppData/Roaming/openeo-python-client"
21+
else:
22+
expected = Path(__file__).parent / "data/user_dirs/config/openeo-python-client"
23+
assert get_user_config_dir() == expected
2624

2725

2826
def test_get_user_data_dir():
29-
# For Linux/Mac we configure the config and data directories in conftest.py
30-
# via the environment variables XDG_CONFIG_HOME and XDG_DATA_HOME.
31-
# But on Windows we need to set APPDATA instead, and we don't have separate
32-
# variables for config and data.
3327
if platform.system() == "Windows":
34-
os.environ["APPDATA"] = str(Path(__file__).parent / "data/user_dirs/data")
35-
assert get_user_data_dir() == Path(__file__).parent / "data/user_dirs/data/openeo-python-client"
28+
expected = Path(__file__).parent / "data/user_dirs/AppData/Roaming/openeo-python-client"
29+
else:
30+
expected = Path(__file__).parent / "data/user_dirs/data/openeo-python-client"
31+
assert get_user_data_dir() == expected
3632

3733

3834
class TestClientConfig:

0 commit comments

Comments
 (0)