Skip to content

TST/DEP: drop pytest-astropy in favor of corresponding, direct test dependencies#18784

Draft
neutrinoceros wants to merge 1 commit intoastropy:mainfrom
neutrinoceros:tst/drop-pytest-astropy
Draft

TST/DEP: drop pytest-astropy in favor of corresponding, direct test dependencies#18784
neutrinoceros wants to merge 1 commit intoastropy:mainfrom
neutrinoceros:tst/drop-pytest-astropy

Conversation

@neutrinoceros
Copy link
Copy Markdown
Contributor

@neutrinoceros neutrinoceros commented Oct 26, 2025

Description

Based of #18780

fix #18783

  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

@neutrinoceros neutrinoceros added this to the v7.2.0 milestone Oct 26, 2025
@github-actions
Copy link
Copy Markdown
Contributor

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

@github-actions
Copy link
Copy Markdown
Contributor

👋 Thank you for your draft pull request! Do you know that you can use [ci skip] or [skip ci] in your commit messages to skip running continuous integration tests until you are ready?

@neutrinoceros
Copy link
Copy Markdown
Contributor Author

Interesting. Looks like the --run-slow flag (and corresponding @pytest.mark.slow marker) are defined in some plugin that's pulled from pytest-astropy, but I haven't been able to identified which one yet.

@neutrinoceros
Copy link
Copy Markdown
Contributor Author

of course, it's from pytest-astropy itself.

@neutrinoceros
Copy link
Copy Markdown
Contributor Author

6804a6_2a566775e2464e6884a9bcab4c3060f8_mv2 gif_w=500

@pllim
Copy link
Copy Markdown
Member

pllim commented Oct 28, 2025

Haha yes... It also has --run-hugemem, see https://github.com/astropy/pytest-astropy/blob/main/pytest_astropy/plugin.py

@pllim
Copy link
Copy Markdown
Member

pllim commented Oct 28, 2025

So yeah I am not sure if this is feasible without refactoring pytest-astropy itself... Maybe open discussion on astropy-dev if you still want to pursue?

@neutrinoceros
Copy link
Copy Markdown
Contributor Author

I do want to continue experimenting with this, but I don't think the problems I'm after can be addressed from pytest-astropy itself without breaking its users.

@neutrinoceros
Copy link
Copy Markdown
Contributor Author

(and with the impeding feature freeze, I'll have to postpone this work until at least next week)

@astrofrog astrofrog modified the milestones: v7.2.0, v8.0.0 Nov 3, 2025
@neutrinoceros neutrinoceros force-pushed the tst/drop-pytest-astropy branch from 2e23c32 to ca53c65 Compare November 11, 2025 08:36
@neutrinoceros
Copy link
Copy Markdown
Contributor Author

Turns out vendoring the contents of that plugin within our root conftest.py is actually trivial. I just suspected it could not be, which is why I didn't prioritize this earlier.
Any way this should be much more stable now. Note that it's still based of #18780 though, but I think I could avoid that coupling. I'll try this next once CI is clear.

@neutrinoceros neutrinoceros force-pushed the tst/drop-pytest-astropy branch from ca53c65 to 3924e50 Compare November 11, 2025 08:50
@neutrinoceros neutrinoceros added the Extra CI Run cron CI as part of PR label Nov 11, 2025
@neutrinoceros
Copy link
Copy Markdown
Contributor Author

I'm seeing a couple unrelated failures caused by #18880

@neutrinoceros
Copy link
Copy Markdown
Contributor Author

other failures I'm seeing are already handled in existing PRs

@pllim
Copy link
Copy Markdown
Member

pllim commented Nov 11, 2025

The challenge isn't code, but people. We wanted the plugin stuff in pytest-astropy so other packages could also use it without requiring astropy, but they were so trivial that we did not want to create a whole new package just for them.

Now, they been upstream long enough that we probably have a number of packages using them, and have to keep maintaining them. So copying them over is just duplicating code.

This definitely need more discussion.

@neutrinoceros
Copy link
Copy Markdown
Contributor Author

neutrinoceros commented Nov 11, 2025

we could easily make these markers into their own plugin if duplication must be avoided, but for what it's worth:

  • duplicating ~50 lines of code seems like a (much) lesser evil than irreproducible builds
  • I don't think we have to make this change throughout the entire ecosystem; it's diminishing returns from here, but astropy being a core package means (to me) it needs to adhere to strict(er) quality requirements

@pllim
Copy link
Copy Markdown
Member

pllim commented Nov 11, 2025

Moving them anywhere now would create churn. We have to find and inform all the affected downstream packages. And then go through deprecation period and face some resistance. And then still keep them going while deprecated. And then finally we have to remove them.

@neutrinoceros
Copy link
Copy Markdown
Contributor Author

neutrinoceros commented Nov 11, 2025

We have to find and inform all the affected downstream packages.

why ? couldn't we just keep pytest-astropy as the "batteries included" option, even if we stop dog-fooding it in astropy itself ? I glanced over it and it didn't seem too burdensome to maintain (no release for 2 years and it's still working for everyone, as far as I can tell). Am I missing anything ?

@pllim
Copy link
Copy Markdown
Member

pllim commented Nov 11, 2025

So you are saying we create a new package for the plugin and then include that in pytest-astropy, instead of moving it here?

@neutrinoceros
Copy link
Copy Markdown
Contributor Author

Not really. I would prefer that the code we use to test the core library live in the same repo, which is what the current state of the branch does, and leave pytest-astropy live its life as the provider of these functionality for everyone else that choose to adopt it.

But if we must avoid code duplication at all cost, there are other avenues. Though, it seems we agree that they are highly disruptive and undesirable.

@neutrinoceros neutrinoceros force-pushed the tst/drop-pytest-astropy branch from 664945e to b6673f9 Compare November 11, 2025 16:41
@neutrinoceros
Copy link
Copy Markdown
Contributor Author

That said, it would make sense to isolate the plugin into its own package and make pytest-astropy (and maybe astropy itself) depend on it. It shouldn't have user-facing implications, would avoid duplication entirely, and would allow anyone who needs the plugin to drop other pytest plugins from pytest-astropy they don't need.
But that can also be done in the future, if judged necessary, rather than now

@neutrinoceros
Copy link
Copy Markdown
Contributor Author

As mentionned in #18882, I think my port of the slow test marker doesn't work after all, which could explain at least some of the failures seen in CI. I'll take this one back to the shop for now.

@neutrinoceros neutrinoceros marked this pull request as draft November 12, 2025 08:08
@neutrinoceros
Copy link
Copy Markdown
Contributor Author

Got it. What's broken is specifically runnings test with --pyargs: since the markers are only defined in a repo-level conftest, they are not available when running the suite for an installed package. I think I can make this much easier to understand and debug using pytest's strict markers, but I'll still need to think about how to fix it. Right now, a separate, minimal plugin package looks like the only option to me.

@neutrinoceros
Copy link
Copy Markdown
Contributor Author

I rebased this on top of #18890 to prevent further avoidable mistakes with marker registration, and I moved the plugin parts from pytest-astropy to our other, embedded conftest.py, hoping this will work in all conditions. If it doesn't, I'll need to upstream the discussion.

@neutrinoceros neutrinoceros changed the title TST/DEP: drop pytest-astropy in favor of corresponding, direct test dependencies TST/DEP: drop pytest-astropy in favor of corresponding, direct test dependencies (blocked by #18890) Nov 12, 2025
@neutrinoceros
Copy link
Copy Markdown
Contributor Author

Welp, that didn't work. Let's take this outside. astropy/pytest-astropy#73

@neutrinoceros
Copy link
Copy Markdown
Contributor Author

Since the markers must be provided by a pytest plugin, let's try using a patched version of pytest-astropy (from my fork) that doesn't include any dependency besides pytest.

@neutrinoceros neutrinoceros force-pushed the tst/drop-pytest-astropy branch 3 times, most recently from b05a1e2 to 121b8b1 Compare November 13, 2025 09:33
@neutrinoceros neutrinoceros force-pushed the tst/drop-pytest-astropy branch from 121b8b1 to 731e492 Compare November 13, 2025 13:29
@neutrinoceros neutrinoceros changed the title TST/DEP: drop pytest-astropy in favor of corresponding, direct test dependencies (blocked by #18890) TST/DEP: drop pytest-astropy in favor of corresponding, direct test dependencies Nov 13, 2025
@neutrinoceros
Copy link
Copy Markdown
Contributor Author

I'll remove the "extra CI" label for now. I agree it should run when this is stable enough, but it doesn't seem worth the extra CPU time at the current proof-of-concept stage.

@neutrinoceros neutrinoceros removed the Extra CI Run cron CI as part of PR label Nov 13, 2025
@eerovaher
Copy link
Copy Markdown
Member

Can the markers be defined in astropy/conftest.py and also in docs/conftest.py? Such duplication isn't good but we are duplicating conftest.py contents already. And perhaps the markers are not needed in docs, in which case we could define them only in astropy/conftest.py.

@neutrinoceros
Copy link
Copy Markdown
Contributor Author

Can the markers be defined in astropy/conftest.py and also in docs/conftest.py? Such duplication isn't good but we are duplicating conftest.py contents already

neither will be discovered by pytest when running from an arbitrary location with --pyargs so I think the marker have to be provided by a plugin.

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.

TST/DEP: replace pytest-astropy with corresponding, direct dependencies

4 participants