Skip to content

Conversation

@rossbar
Copy link
Contributor

@rossbar rossbar commented Oct 18, 2025

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

* 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":
Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor

@mattgebert mattgebert Oct 19, 2025

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.

Copy link
Contributor Author

@rossbar rossbar Oct 20, 2025

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!

Copy link
Contributor

Choose a reason for hiding this comment

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

My concern with using replace is that it isn't exclusively targeting the file paths in the string. My vote is to use {example_module} to guarantee that even with future changes only the path changes, and we also avoid the conditional. I just confirmed locally (Mac) that this works correctly:

Image

Copy link
Contributor

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.

Copy link
Contributor

@mattgebert mattgebert left a 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)
Copy link
Contributor

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":
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants