diff --git a/tests/test_tdx_provider_package.py b/tests/test_tdx_provider_package.py index dcbd9fe..9f636e2 100644 --- a/tests/test_tdx_provider_package.py +++ b/tests/test_tdx_provider_package.py @@ -24,6 +24,7 @@ from tests.test_tdx_source_request_adapter import ( EchoTqlexClient, FakeTdxClient, + _expected_default_tdx_stats_cache_root, _minimal_stat2_line, _minimal_stat_line, _stats_zip_bytes, @@ -6769,9 +6770,7 @@ def test_tdx_provider_installed_from_wheel_is_discovered_and_can_route( ).stdout.strip() for cwd in (first_cwd, second_cwd) ] - expected_cache = str( - (local_app_data / "AxData" / "cache" / "tdx" / "stats").resolve() - ) + expected_cache = str(_expected_default_tdx_stats_cache_root(local_app_data)) assert cache_paths == [expected_cache, expected_cache] diff --git a/tests/test_tdx_source_request_adapter.py b/tests/test_tdx_source_request_adapter.py index e6ae736..c4e033d 100644 --- a/tests/test_tdx_source_request_adapter.py +++ b/tests/test_tdx_source_request_adapter.py @@ -5515,6 +5515,22 @@ def test_tdx_stats_resource_reuses_parsed_resource_in_process(tmp_path): assert second is first +def _expected_default_tdx_stats_cache_root(local_app_data: Path) -> Path: + """Expected default TDX stats cache root for the current OS. + + Mirrors ``axdata_source_tdx.stats_cache.user_tdx_stats_cache_root`` so the + assertion matches the running platform instead of assuming the Windows + ``LOCALAPPDATA`` layout. + """ + + if os.name == "nt": + return (local_app_data / "AxData" / "cache" / "tdx" / "stats").resolve() + if sys.platform == "darwin": + return (Path.home() / "Library" / "Caches" / "AxData" / "tdx" / "stats").resolve() + base = Path(os.getenv("XDG_CACHE_HOME") or (Path.home() / ".cache")) + return (base / "axdata" / "tdx" / "stats").resolve() + + def test_tdx_direct_adapter_default_stats_cache_is_independent_of_cwd(monkeypatch, tmp_path): from axdata_source_tdx.stats_cache import default_tdx_stats_cache_root @@ -5532,7 +5548,7 @@ def test_tdx_direct_adapter_default_stats_cache_is_independent_of_cwd(monkeypatc second = default_tdx_stats_cache_root() assert first == second - assert first == (local_app_data / "AxData" / "cache" / "tdx" / "stats").resolve() + assert first == _expected_default_tdx_stats_cache_root(local_app_data) def test_tdx_adapter_refreshes_stats_cache_older_than_previous_trade_date(monkeypatch, tmp_path):