Skip to content

Conversation

@bittner
Copy link
Member

@bittner bittner commented Dec 10, 2025

Adds a new context manager to allow verifying the code's independence of the CLI execution location.

Enhances the documentation by adding an API documentation chapter, auto-generated from source code.

@bittner bittner self-assigned this Dec 10, 2025
@bittner bittner added documentation Improvements or additions to documentation enhancement New feature or request labels Dec 10, 2025
@bittner bittner requested a review from Copilot December 13, 2025 00:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new RandomDirectoryContext context manager to help test CLI programs' independence from their execution directory, and introduces auto-generated API documentation using Sphinx's autodoc extension.

  • Adds RandomDirectoryContext class that temporarily changes to a random temporary directory during test execution
  • Sets up Sphinx autodoc for automatic API documentation generation from source code docstrings
  • Updates tutorial documentation to include usage examples for the new context manager

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
cli_test_helpers/decorators.py Implements RandomDirectoryContext class inheriting from TemporaryDirectory with directory switching logic and enhanced docstrings for ArgvContext
cli_test_helpers/init.py Exports the new RandomDirectoryContext class in the package's public API
tests/test_decorators.py Adds test case test_random_directory_context() to verify directory switching and restoration behavior
pyproject.toml Adds PTH109 to ruff ignore list (allows os.getcwd() usage instead of requiring Path.cwd())
docs/conf.py Configures Sphinx to import the package and enables autodoc extension for API documentation
docs/index.rst Adds API documentation page to the documentation table of contents
docs/api.rst Creates new API documentation page with autoclass/autofunction directives for all public APIs
docs/tutorial.rst Updates references to use Sphinx cross-references and adds tutorial section for RandomDirectoryContext

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bittner
Copy link
Member Author

bittner commented Dec 13, 2025

@copilot The tests fail on macOS only. See job 57723418134 for an example:

>           assert new_dir == random_dir, "Does't behave like TemporaryDirectory"
E           AssertionError: Does't behave like TemporaryDirectory
E           assert '/private/var...T/tmpp6s4ranh' == '/var/folders...T/tmpp6s4ranh'
E             
E             - /var/folders/_l/91ns3hs96sd11p4_lzxh1l140000gn/T/tmpp6s4ranh
E             + /private/var/folders/_l/91ns3hs96sd11p4_lzxh1l140000gn/T/tmpp6s4ranh
E             ? ++++++++

os.getcwd() appears to yield the same path but prefixed with /private/.

  • Why does the TemporaryDirectory context manager yield a different directory than os.getcwd()?
  • Is the infrastructure setup on the macOS runners know to be particular? (Is "private" a mount point or a symbolic link?)
  • Is there a better, more robust choice instead of TemporaryDirectory as a base class?

Copy link
Contributor

Copilot AI commented Dec 13, 2025

@bittner I've opened a new pull request, #69, to work on those changes. Once the pull request is ready, I'll request review from you.

The test failed on macOS runners previously, due to an unresolved symbolic link
@bittner bittner force-pushed the feature/random-directory-context branch from 557349a to b613564 Compare December 13, 2025 00:35
@bittner bittner merged commit cf09c2d into main Dec 13, 2025
38 checks passed
@bittner bittner deleted the feature/random-directory-context branch December 13, 2025 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants