Skip to content

fix(tests): replace FakePath subclass with Path.exists patch for Python 3.12 compatibility#2244

Closed
teyrebaz33 wants to merge 1 commit intoNousResearch:mainfrom
teyrebaz33:fix/gateway-service-test-path-mock-python312
Closed

fix(tests): replace FakePath subclass with Path.exists patch for Python 3.12 compatibility#2244
teyrebaz33 wants to merge 1 commit intoNousResearch:mainfrom
teyrebaz33:fix/gateway-service-test-path-mock-python312

Conversation

@teyrebaz33
Copy link
Copy Markdown
Contributor

Fixes #2243

Problem

TestEnsureUserSystemdEnv::test_sets_xdg_runtime_dir_when_missing fails on Python 3.12. The test used a FakePath subclass overriding __new__ to redirect /run/user/42 to a temp directory. In Python 3.12, PosixPath.__new__ ignores the redirected path argument and re-initializes from the original string, so exists() returns False and XDG_RUNTIME_DIR is never set.

Fix

Replace the FakePath subclass with monkeypatch.setattr(gateway_cli.Path, "exists", ...) — patches the method directly on the class used by the module under test.

Changes

  • tests/hermes_cli/test_gateway_service.py: 4 insertions, 12 deletions — single test method, no production code changes
@teyrebaz33 teyrebaz33 force-pushed the fix/gateway-service-test-path-mock-python312 branch from 5442960 to bf99a3d Compare March 21, 2026 09:36
@teknium1
Copy link
Copy Markdown
Contributor

Duplicate of #2261, merged via #2444. Thanks for the contribution!

@teknium1 teknium1 closed this Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants