Skip to content

MAINT: Remove astropy.test(), should use pytest directly#16208

Closed
MridulS wants to merge 1 commit into
astropy:mainfrom
MridulS:remove_test_runner
Closed

MAINT: Remove astropy.test(), should use pytest directly#16208
MridulS wants to merge 1 commit into
astropy:mainfrom
MridulS:remove_test_runner

Conversation

@MridulS

@MridulS MridulS commented Mar 17, 2024

Copy link
Copy Markdown
Contributor

Blocked by:

This PR addresses one of the points brought forward in #16177.

This removes astropy.test(), this does not deprecate/remove TestRunner. We can do a deprecation too (astropy.test()) if folks think this is a tad bit aggressive for downstream code 😅 . We can go down the sunpy route too and add a direct call to pytest.main from astropy.test but I would argue let's keep the testing separate from final user install. A user shouldn't really ever worry about installing a broken astropy wheel. It should be caught in the CI first! If a user is doing a source build install I think it's fair to assume they are comfortable with calling pytest directly from command line.

This is the first step towards removing TestRunner. There is a lot of code in TestRunner that hasn't been touched in 10 years and things will only keep on evolving in pytest to play maintenance catchup 😅

@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.

@MridulS MridulS force-pushed the remove_test_runner branch 2 times, most recently from 0facccd to b1451d0 Compare March 17, 2024 21:55
Comment thread tox.ini Outdated
@pllim pllim added this to the v6.1.0 milestone Mar 18, 2024
@pllim pllim added Refactoring API change PRs and issues that change an existing API, possibly requiring a deprecation period testing labels Mar 18, 2024
@pllim

pllim commented Mar 18, 2024

Copy link
Copy Markdown
Member

Thanks!

I think this still needs a change log, because we had advertised astropy.test() in RC testing in the past, for that one person who wonders why 6.1rc testing is different...

@pllim

pllim commented Mar 18, 2024

Copy link
Copy Markdown
Member

p.s. When requested changes are addressed, this also would need a "Extra CI" label.

Comment thread astropy/utils/tests/test_introspection.py
Comment thread docs/install.rst
@saimn

saimn commented Mar 18, 2024

Copy link
Copy Markdown
Contributor

So this would imply that RC testing should be done with pytest --pyargs astropy ?

@MridulS MridulS force-pushed the remove_test_runner branch from becae4a to 1d01377 Compare March 20, 2024 22:20
@MridulS

MridulS commented Mar 20, 2024

Copy link
Copy Markdown
Contributor Author

So this would imply that RC testing should be done with pytest --pyargs astropy ?

Yes, assuming all the paths are fine, this should work just fine. I tried this out with https://github.com/astropy/astropy/wiki/v6.0-RC-Testing and it worked fine with pytest --pyargs astropy --remote-data

@MridulS MridulS force-pushed the remove_test_runner branch from 1d01377 to e43ba80 Compare March 24, 2024 03:29
@MridulS MridulS requested review from astrofrog, mhvk and saimn March 24, 2024 03:30

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A few small further comments...

Comment thread docs/development/testguide.rst Outdated
``astropy.test()`` to prevent test runs from taking too long. These tests can
be run by ``astropy.test()`` by adding the ``remote_data='any'`` flag. Turn on
``pytest`` to prevent test runs from taking too long. These tests can
be run by ``pytest`` by adding the ``remote_data='any'`` flag. Turn on

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is doubled up. This line and l.308 should be combined into

be included by running ``pytest --remote-data=any``.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Done in #16561.


import astropy
astropy.test(package='time')
changes do not break existing code, by running the Astropy tests.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a bit out of date in general, since we now suggest to use tox. I'd either skip the example and go straight to For more details on... or, perhaps better, rewrite as,

   changes do not break existing code, by running the Astropy tests,
   e.g., by running::

      tox -e test

   For more details on running ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am making alll the Sphinx doc changes now in #16561. For this bit I am just linking to the testing guidelines page as the one and only-one reference on running tests.

Comment thread docs/install.rst Outdated

The easiest way to test if your installed version of ``astropy`` is running
correctly is to use the :ref:`astropy.test()` function::
To run tests after installing ``astropy`` we need to install ``pytest`` and

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here, the changes are good as is, since we've not installed from source.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These changes conflict with #16555, so I would suggest reverting all changes to install.rst here.

@hamogu

hamogu commented Jun 12, 2024

Copy link
Copy Markdown
Member

There seems to be broad agreement by reviewers that this is the right direction to take except for the small comments by @mhvk.
@MridulS : Do you have time to add those or do you want me to add it to your PR?

@MridulS

MridulS commented Jun 12, 2024

Copy link
Copy Markdown
Contributor Author

@MridulS : Do you have time to add those or do you want me to add it to your PR?

I can do it later this week, unless someone gets to it before that :)

@hamogu hamogu mentioned this pull request Jun 14, 2024
1 task
@taldcroft

Copy link
Copy Markdown
Member

This is almost certain to conflict with #16561 since that renames development_workflow.rst. It sounds like everyone is agreed on the idea of removing astropy.test(), so I think the easiest is if I apply these doc changes in #16561. This is independent of removing the code that implements astropy.test(). Sound OK?

This might imply that we don't merge this PR before #16561 so we don't have documentation of something that doesn't work.

@pllim pllim marked this pull request as draft June 14, 2024 20:14

import astropy
astropy.test(package='time')
changes do not break existing code, by running the Astropy tests.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am making alll the Sphinx doc changes now in #16561. For this bit I am just linking to the testing guidelines page as the one and only-one reference on running tests.

Comment thread docs/development/testguide.rst Outdated
``astropy.test()`` to prevent test runs from taking too long. These tests can
be run by ``astropy.test()`` by adding the ``remote_data='any'`` flag. Turn on
``pytest`` to prevent test runs from taking too long. These tests can
be run by ``pytest`` by adding the ``remote_data='any'`` flag. Turn on

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Done in #16561.

Comment thread docs/development/testguide.rst Outdated

pytest astropy/wcs/index.rst

.. _astropy.test():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Done in #16561.

Comment thread docs/development/testguide.rst Outdated
Pass ``-n auto`` to create the same number of processes as cores
on your machine.

Similarly, this feature can be invoked from ``astropy.test``::

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Done in #16561.

Comment thread docs/development/testguide.rst Outdated
running framework. For example doctests and detailed documentation on how to
write them, see the full :mod:`doctest` documentation.

.. note::

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Done in #16561.

Comment thread docs/install.rst Outdated

The easiest way to test if your installed version of ``astropy`` is running
correctly is to use the :ref:`astropy.test()` function::
To run tests after installing ``astropy`` we need to install ``pytest`` and

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These changes conflict with #16555, so I would suggest reverting all changes to install.rst here.

@github-actions github-actions Bot added the Close? Tell stale bot that this issue/PR is stale label Aug 21, 2024
@github-actions

Copy link
Copy Markdown
Contributor

Hi humans 👋 - this pull request hasn't had any new commits for approximately 4 months. I plan to close this in 30 days if the pull request doesn't have any new commits by then.

In lieu of a stalled pull request, please consider closing this and open an issue instead if a reminder is needed to revisit in the future. Maintainers may also choose to add keep-open label to keep this PR open but it is discouraged unless absolutely necessary.

If this PR still needs to be reviewed, as an author, you can rebase it to reset the clock.

If you believe I commented on this pull request incorrectly, please report this here.

@astrofrog

Copy link
Copy Markdown
Member

I've rebased to remove changes to the documentation but haven't changed anything else. How do people feel about deprecation vs removal?

@astrofrog astrofrog removed their request for review September 5, 2024 11:31

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good modulo a small change to the comments.

On the larger question, I think a deprecation error would be good, since we have been asking people to use astropy.test() since forever... I guess it can just be a __getattr__ in the main __init__.py?

@@ -63,8 +63,8 @@ def test_find_mod_objs():

# just check for astropy.test ... other things might be added, so we

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should adjust the comment here to be "just check for astropy.conf"

@pllim pllim Mar 11, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Update: This test update (with Marten's comment applied) is now #17873 . Thanks again! I added you both as co-authors.

@pllim

pllim commented Sep 5, 2024

Copy link
Copy Markdown
Member

How do people feel about deprecation vs removal?

I vote deprecation because we have been asking people to run that for years during RC testing. Release manager for next release also need to remember to modify RC testing instructions.

@pllim pllim removed the Close? Tell stale bot that this issue/PR is stale label Sep 5, 2024
@saimn

saimn commented Sep 5, 2024

Copy link
Copy Markdown
Contributor

I think we should deprecate TestRunner directly, as proposed in #16177. If we no more use it and barely maintain it then it's better to be clear about its future.

@mhvk

mhvk commented Sep 5, 2024

Copy link
Copy Markdown
Contributor

Thinking about it more, I'm actually OK with just removing it, as long as people trying to use astropy.test get a clear error with instructions of what to do instead.

@pllim

pllim commented Sep 5, 2024

Copy link
Copy Markdown
Member

synphot uses the test runner, so deprecating it without much notice would be annoying. I am sure a lot of packages use it (whether they know it or not) as a result of the package-template.

@neutrinoceros

Copy link
Copy Markdown
Contributor

It doesn't seem likely to get unstuck in time for the 7.0 feature freeze so I'll remove the milestone.

@neutrinoceros neutrinoceros removed this from the v7.0.0 milestone Oct 23, 2024
@github-actions github-actions Bot added the Close? Tell stale bot that this issue/PR is stale label Feb 3, 2025
@github-actions

github-actions Bot commented Feb 3, 2025

Copy link
Copy Markdown
Contributor

Hi humans 👋 - this pull request hasn't had any new commits for approximately 4 months. I plan to close this in 30 days if the pull request doesn't have any new commits by then.

In lieu of a stalled pull request, please consider closing this and open an issue instead if a reminder is needed to revisit in the future. Maintainers may also choose to add keep-open label to keep this PR open but it is discouraged unless absolutely necessary.

If this PR still needs to be reviewed, as an author, you can rebase it to reset the clock.

If you believe I commented on this pull request incorrectly, please report this here.

@pllim

pllim commented Feb 6, 2025

Copy link
Copy Markdown
Member

Direct removal without deprecation is too controversial, so I am closing this PR but I made a note on #16177 to refer back to this when we get to it in the future. Additionally, I credited Mridul as co-author over at #17732 for the change in tox.ini that is not controversial and can be merged much sooner. Thank you!

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

Labels

API change PRs and issues that change an existing API, possibly requiring a deprecation period Close? Tell stale bot that this issue/PR is stale Docs installation Refactoring testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants