-
-
Couldn't load subscription status.
- Fork 169
MAINT: Add missing hooks tests. #653
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
base: main
Are you sure you want to change the base?
Conversation
* replace path separators on windows * Add drive to path for windows
| numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring | ||
| """ | ||
| ) | ||
| if sys.platform == "win32": |
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.
Another option could be string.Template with os.path.sep as a substitute var... I have no preference
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.
What about replacing the occurrences of the hardcoded path with str(example_module) using an f-string like this?
- numpydoc/tests/hooks/example_module.py
+ f'{str(example_module)}'As I understand it pathlib should pick up the separator from the OS, and we already have the path to the example module. Then, we could avoid the replace altogether.
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.
os.sep is better and clearer. Maybe you don't need to even add the conditional; always perform the replacement from the raw string.
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.
Both good ideas!
My vote for now would be to get this in as-is with minimal changes to ensure that all the tests are being run, then tackle improvements to the test setup in a followup!
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.
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.
I like @stefmolin's suggestion, this also clears the formatting much more.
Don't mind if this is a follow up PR but we should do it.
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.
While we're changing the test suite to make sure the hook tests run, I suggest we add --pre flag for the pre-release install in the testing CI test.yml.
| if files: | ||
| expected_dir = Path("/") if expected_reason == "file system root" else tmp_path | ||
| if expected_reason == "file system root": | ||
| expected_dir = Path(tmp_path.drive + tmp_path.root) |
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.
This whole block edit could instead be
Path(tmp_path.anchor) if expected_reason == "file system root" else tmp_path
Anchor simplifies the addition of the drive and root, I believe.
| numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring | ||
| """ | ||
| ) | ||
| if sys.platform == "win32": |
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.
I like @stefmolin's suggestion, this also clears the formatting much more.
Don't mind if this is a follow up PR but we should do it.

The
tests/hookstests are not being run on CI because the tests themselves are not included in the package. The--pyargspytest flag tells pytest to run the tests on the installed package, so since the hook tests are not included they are not run.