Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 13, 2025

The RandomDirectoryContext test failed on macOS because /var is symlinked to /private/var. TemporaryDirectory.name returns the symlink path while os.getcwd() resolves to the real path, causing the assertion to fail.

Changes

  • RandomDirectoryContext.__enter__(): Return os.getcwd() instead of self.name to ensure consistent path resolution across platforms
  • Spelling fixes: Corrected "mimick" → "mimic", "Does't" → "Doesn't", "identical the ones" → "identical to the ones"

Example

# Before (fails on macOS):
def __enter__(self):
    self.__prev_dir = os.getcwd()
    super().__enter__()
    os.chdir(self.name)
    return self.name  # /var/folders/... (symlink)

# After (works on all platforms):
def __enter__(self):
    self.__prev_dir = os.getcwd()
    super().__enter__()
    os.chdir(self.name)
    return os.getcwd()  # /private/var/folders/... (resolved)

Since we've already changed to the temporary directory, os.getcwd() returns the resolved real path, eliminating platform-specific symlink inconsistencies.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: bittner <665072+bittner@users.noreply.github.com>
Copilot AI changed the title [WIP] Add RandomDirectoryContext manager and API docs Fix macOS test failure due to symlink path resolution in RandomDirectoryContext Dec 13, 2025
Copilot AI requested a review from bittner December 13, 2025 00:24
@bittner bittner force-pushed the feature/random-directory-context branch from 557349a to b613564 Compare December 13, 2025 00:35
Base automatically changed from feature/random-directory-context to main December 13, 2025 00:47
@bittner
Copy link
Member

bittner commented Dec 13, 2025

Integrated manually in original PR.

@bittner bittner closed this Dec 13, 2025
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.

2 participants