Skip to content
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

Copy conftest to top-level directory #516

Closed
wants to merge 1 commit into from

Conversation

larrybradley
Copy link
Member

This fixes the issue where the installed package versions were not shown during tox tests (but where show running pytest locally).

This PR also uses numpy 1.25 print formatting to workaround the NumPy 2.0 repr changes that causes doctest to fail.

@larrybradley
Copy link
Member Author

@bsipocz Did you ever figure out the conftest.py issue? The mere presence of conftest.py (even if it's empty) in the top-level directory causes this failure. I can reproduce this locally, and the Cython extensions are being built in the installed package in the ./tox directory. Somehow pytest resolves the path to the source checkout instead of the installed version when conftest.py is in the top-level directory of the source. I've tried many things and I can't figure this out!

This is now a problem because I need to add np.set_printoptions(legacy='1.25') in the top-level conftest.py for the doctests in docs.

@larrybradley
Copy link
Member Author

This same issue affects photutils.

@bsipocz
Copy link
Member

bsipocz commented Sep 11, 2023

Nope, this was a constant annoyance, but I didn't get to the bottom of it. And since we started to use pip freeze in CI, it's kind of not that important for me anymore to get tox work well with the header (basically I never use tox locally).
The only caveat and annoyance when a dev version package doesn't provide proper version info for pip, and it only shows up as e.g. 2.0.0.dev0.

As for the printoptions, for astroquery I only added it to astroquery/conftest.py, but not to the very top level one, maybe that would be enough here, too?

@larrybradley
Copy link
Member Author

Another data point: if I change the tox command to:
python -c 'import sys; from regions import test; sys.exit(test())'
(instead of using pytest --pyargs regions)

it works. But that doesn't test the docs.

@larrybradley
Copy link
Member Author

@astrofrog Have you seen anything like this?

Astropy has extensions and has a conftest.py in the top-level directory -- and it works fine.

@larrybradley
Copy link
Member Author

larrybradley commented Sep 11, 2023

As for the printoptions, for astroquery I only added it to astroquery/conftest.py, but not to the very top level one, maybe that would be enough here, too?

I tried that, but without the legacy printoptions in the top-level conftest, running pytest docs (or pytest .) locally fails.

@bsipocz
Copy link
Member

bsipocz commented Sep 12, 2023

I tried that, but without the legacy printoptions in the top-level conftest, running pytest docs (or pytest .) locally fails.

Dang, you're right, it doesn't work for us either. Sometimes I added to my routine to specify package/conftest.py when running a single rst file (I can't remember why I started, something else didn't work), and it masked over this same issue.

Thanks for investigating!

@larrybradley
Copy link
Member Author

I'm not sure it's possible to have a top-level conftest.py file in a package with extensions. Apparently pytest adds any directory with conftest.py to the python sys.path, which here means the source package without built extensions.

@larrybradley larrybradley deleted the conftest branch September 19, 2023 17:47
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.

2 participants