-
Notifications
You must be signed in to change notification settings - Fork 4
Add RandomDirectoryContext manager and API docs
#66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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
RandomDirectoryContextclass 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.
|
@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 ? ++++++++
|
The test failed on macOS runners previously, due to an unresolved symbolic link
557349a to
b613564
Compare
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.