Skip to content

test(tdx): make stats cache root assertions platform-aware (fix macOS/Linux failures) - #1

Open
mayaa6 wants to merge 1 commit into
electkismet:mainfrom
mayaa6:fix/tdx-stats-cache-test-platform-assumption
Open

test(tdx): make stats cache root assertions platform-aware (fix macOS/Linux failures)#1
mayaa6 wants to merge 1 commit into
electkismet:mainfrom
mayaa6:fix/tdx-stats-cache-test-platform-assumption

Conversation

@mayaa6

@mayaa6 mayaa6 commented Jul 31, 2026

Copy link
Copy Markdown

Summary

Two TDX stats-cache tests hard-code the Windows LOCALAPPDATA cache
layout as the expected default cache root, so they fail on macOS and Linux
even though the code under test is correct.

axdata_source_tdx.stats_cache.user_tdx_stats_cache_root() already returns
the right per-OS location:

OS Default TDX stats cache root
Windows %LOCALAPPDATA%\AxData\cache\tdx\stats
macOS ~/Library/Caches/AxData/tdx/stats
Linux $XDG_CACHE_HOME/axdata/tdx/stats (or ~/.cache/...)

But the tests asserted the Windows path unconditionally:

assert first == (local_app_data / "AxData" / "cache" / "tdx" / "stats").resolve()

On macOS this fails with e.g.:

AssertionError: assert PosixPath('/Users/<you>/Library/Caches/AxData/tdx/stats')
             == PosixPath('/.../local-app-data/AxData/cache/tdx/stats')

Change

Add a small _expected_default_tdx_stats_cache_root() helper that mirrors the
production per-OS branch, and use it in both tests so the expectation follows
the running platform. The Windows expectation is unchanged, and the
cwd-independence assertion (first == second) is untouched.

Affected tests

  • tests/test_tdx_source_request_adapter.py::test_tdx_direct_adapter_default_stats_cache_is_independent_of_cwd
  • tests/test_tdx_provider_package.py::test_tdx_provider_installed_from_wheel_is_discovered_and_can_route

Verification (macOS, Python 3.12)

Before: both tests fail. After:

$ python -m pytest -q \
    tests/test_tdx_source_request_adapter.py::test_tdx_direct_adapter_default_stats_cache_is_independent_of_cwd \
    tests/test_tdx_provider_package.py::test_tdx_provider_installed_from_wheel_is_discovered_and_can_route
2 passed

No production code changed — this is a test-only, platform-portability fix.

🤖 Generated with Claude Code

The two stats-cache tests hard-coded the Windows LOCALAPPDATA layout
(`AxData/cache/tdx/stats`) as the expected default cache root. On macOS
and Linux the production `user_tdx_stats_cache_root()` correctly returns
`~/Library/Caches/AxData/tdx/stats` and `$XDG_CACHE_HOME/axdata/tdx/stats`
respectively, so both tests failed on non-Windows platforms even though
the code under test was behaving correctly.

Add a small `_expected_default_tdx_stats_cache_root()` helper that mirrors
the production per-OS branch and use it in both tests, so the expectation
follows the running platform. The cwd-independence assertion is unchanged.

Affected tests:
- test_tdx_direct_adapter_default_stats_cache_is_independent_of_cwd
- test_tdx_provider_installed_from_wheel_is_discovered_and_can_route

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant