Add RandomDirectoryContext manager and API docs#66
Merged
Conversation
There was a problem hiding this comment.
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.
Member
Author
|
@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 ? ++++++++
|
Contributor
The test failed on macOS runners previously, due to an unresolved symbolic link
557349a to
b613564
Compare
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.
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.