test(tdx): make stats cache root assertions platform-aware (fix macOS/Linux failures) - #1
Open
mayaa6 wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two TDX stats-cache tests hard-code the Windows
LOCALAPPDATAcachelayout 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 returnsthe right per-OS location:
%LOCALAPPDATA%\AxData\cache\tdx\stats~/Library/Caches/AxData/tdx/stats$XDG_CACHE_HOME/axdata/tdx/stats(or~/.cache/...)But the tests asserted the Windows path unconditionally:
On macOS this fails with e.g.:
Change
Add a small
_expected_default_tdx_stats_cache_root()helper that mirrors theproduction 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_cwdtests/test_tdx_provider_package.py::test_tdx_provider_installed_from_wheel_is_discovered_and_can_routeVerification (macOS, Python 3.12)
Before: both tests fail. After:
No production code changed — this is a test-only, platform-portability fix.
🤖 Generated with Claude Code