Skip to content

Fix unit test to run with astropy 7.1 (and earlier versions) #1575

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

Merged
merged 4 commits into from
May 21, 2025

Conversation

GernotMaier
Copy link
Contributor

@GernotMaier GernotMaier commented May 20, 2025

astropy 7.1 changes the error message

'None is not a valid Unit'

to

None cannot be converted to a Unit

This resulted in failure of tests/unit_tests/data_model/test_format_checkers.py. Change the string matching now to test for a error message starting with None and ending with Unit to cover both old and new versions.

I have tested it by:

  • using my local docker installation with astropy 7.01
  • updated in the image astropy to 7.1

Closes #1574

@GernotMaier GernotMaier self-assigned this May 20, 2025
@GernotMaier GernotMaier marked this pull request as ready for review May 20, 2025 15:27
@GernotMaier GernotMaier requested a review from Copilot May 20, 2025 15:28
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates unit tests to handle both old and new Astropy error messages and logs the change in the project changelog.

  • Adjust pytest.raises match to a regex that covers both Astropy 7.1 and earlier messages
  • Add a one-line entry to docs/changes for this fix

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tests/unit_tests/data_model/test_format_checkers.py Relax error‐message matching to r"^None.*Unit$" for backward compatibility
docs/changes/1575.maintence.md Add changelog entry

GernotMaier and others added 2 commits May 20, 2025 17:30
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

This comment has been minimized.

2 similar comments

This comment has been minimized.

Copy link

Passed

Analysis Details

0 Issues

  • Bug 0 Bugs
  • Vulnerability 0 Vulnerabilities
  • Code Smell 0 Code Smells

Coverage and Duplications

  • Coverage No coverage information (97.20% Estimated after merge)
  • Duplications 0.00% Duplicated Code (0.00% Estimated after merge)

Project ID: gammasim_simtools_AY_ssha9WiFxsX-2oy_w

View in SonarQube

@GernotMaier GernotMaier requested a review from EshitaJoshi May 20, 2025 15:36
@GernotMaier
Copy link
Contributor Author

Thanks @EshitaJoshi

@GernotMaier GernotMaier merged commit 4730fd0 into main May 21, 2025
15 checks passed
@GernotMaier GernotMaier deleted the astropy-7.1 branch May 21, 2025 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

astropy 7.1.0: error message for "None is not a valid unit changed"
2 participants