astroquery icon indicating copy to clipboard operation
astroquery copied to clipboard

TST: Move full conftest.py back to package level

Open pllim opened this issue 9 months ago • 12 comments

Move full conftest.py back to package level because otherwise pytest cannot find it if run on installed code but we still need root level for tox pytest header. This is a follow-up of #3215

Example failing log without this patch: https://github.com/astropy/astropy-integration-testing/actions/runs/13929757409/job/39007964709

With this patch: https://github.com/astropy/astropy-integration-testing/pull/27 produces https://github.com/astropy/astropy-integration-testing/actions/runs/13954373539/job/39061703535?pr=27

See also https://github.com/astropy/ccdproc/pull/884

pllim avatar Mar 19 '25 18:03 pllim

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 69.13%. Comparing base (c1772fd) to head (0167cf2). Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3268      +/-   ##
==========================================
+ Coverage   69.08%   69.13%   +0.05%     
==========================================
  Files         232      233       +1     
  Lines       19673    19705      +32     
==========================================
+ Hits        13591    13623      +32     
  Misses       6082     6082              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Mar 19 '25 18:03 codecov[bot]

Dang, do we really have to do this, it was so great to finally get rid of the duplicate? What about adding a symlink/copy at time of packaging?

bsipocz avatar Mar 19 '25 22:03 bsipocz

What about adding a symlink/copy at time of packaging?

At the time of packaging? How? 👀

pllim avatar Mar 20 '25 02:03 pllim

At the time of packaging? How? 👀

I don't know, but surely there should be a way besides some script hacking.

Btw, if you run pytest with the installed version how do you pick up the [tool:pytest] section from the config files either? A lot is set up there.

bsipocz avatar Mar 20 '25 03:03 bsipocz

how do you pick up the [tool:pytest] section

I can't. That is why I added a astroquery_pytest.ini in the astropy-integration-testing PR linked above, following sunpy's example.

surely there should be a way

Maybe @Cadair can advise, given his expertise in sunpy land?

pllim avatar Mar 20 '25 15:03 pllim

I can't. That is why I added a astroquery_pytest.ini in the astropy-integration-testing PR linked above, following sunpy's example.

Would copying the conftest over would work as the same workaround then? I really don't want to keep two of the same (well, similar and always diverging) file around just for the sake of the testing repo.

bsipocz avatar Mar 20 '25 15:03 bsipocz

Would copying the conftest over would work as the same workaround then?

AFAIK there is no way to tell pytest to select this or that conftest.py for a given run (but please correct me if i am wrong!) so copying conftest.py over will pollute the testing of other packages and that is undesirable.

Another way to ask the question here is how should an end-user test their installed version of astroquery?

pllim avatar Mar 20 '25 15:03 pllim

Another way to ask the question here is how should an end-user test their installed version of astroquery?

The end user's convenience was already take out of the picture when the TestRunner was removed, so I feel not having a file duplicate outweighs a few tests erroring out out is with pytest --pyargs astroquery. I mean these numbers are close enough: 1679 passed, 731 skipped, 2 xfailed, 44 warnings, 4 errors

bsipocz avatar Mar 20 '25 17:03 bsipocz

But let's see if Stuart has a cunning plan.

bsipocz avatar Mar 20 '25 17:03 bsipocz

Just FYI that without this, I could not run astropy integration testing (https://github.com/astropy/astropy-integration-testing/actions/runs/14934084322) for astroquery to test against astropy v7.1.0rc1.

pllim avatar May 09 '25 17:05 pllim

I still wonder if you could just copy over the conftest file the same as you do it for e.g. the sunpy pytest ini file.

Alternative if we could move only the fixtures in there but don't duplicate anything about the headers, etc, that could also work, but I very strongly want to keep the file non-duplicating now that we finally cleaned them up.

bsipocz avatar May 09 '25 18:05 bsipocz

It might work but unfortunately I do not have time to work on it currently. Would be happy to review PR to the integration testing setup though. However, it is important that it is set up in a way that does not affect the other packages under test. AFAIK there is no way to set up package specific conftest.py at that level without some hackery, but I will be happy to be proven wrong.

pllim avatar May 09 '25 19:05 pllim