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

Purge unittest? #245

Merged
merged 8 commits into from
May 26, 2022
Merged

Purge unittest? #245

merged 8 commits into from
May 26, 2022

Conversation

rcomer
Copy link
Member

@rcomer rcomer commented May 26, 2022

🚀 Pull Request

Description

I learned of these tools to help convert unittest tests to pytest-style tests

So obviously I wanted to see what happens if you point them at cf_units! The udunits tests needed a little manual intervention, because the pattern

with pytest.raises(SomeError) as thing:

gives you a different thing to

with self.assertRaises(SomeError) as thing:

Otherwise, this was remarkably painless.

The final commit just gets rid of the pattern import cf_units as unit from one test module. I assume that was a hangover from when cf_units was taken out of the iris.unit module.

Copy link
Member

@pp-mo pp-mo left a comment

Choose a reason for hiding this comment

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

Respect for wading through all of this !
Some tiny suggestions, but basically all good !

cf_units/tests/integration/test_date2num.py Show resolved Hide resolved
cf_units/tests/unit/test__udunits2.py Outdated Show resolved Hide resolved
cf_units/tests/unit/test__udunits2.py Outdated Show resolved Hide resolved
cf_units/tests/unit/test__udunits2.py Outdated Show resolved Hide resolved
@rcomer
Copy link
Member Author

rcomer commented May 26, 2022

Thanks @pp-mo, I've addressed your comments. I'm at a loss what to do about Codacy's objection though.

@pp-mo
Copy link
Member

pp-mo commented May 26, 2022

@rcomer I'm at a loss what to do about Codacy's objection though.

I think it is because 'self' is unused in this method.
So I suppose it "wants" you to remove it from the signature + add "@staticmethod"
But I don't know whether PyTest would take kindly to that or not.
If not, you can just add a line with "self" on it, to evaluate but (presumably) do nothing.

@rcomer
Copy link
Member Author

rcomer commented May 26, 2022

I tried removing that method entirely, and I couldn't see any change in the test output. 🤷‍♀️

@pp-mo pp-mo merged commit cb09e93 into SciTools:main May 26, 2022
@pp-mo
Copy link
Member

pp-mo commented May 26, 2022

Thanks @rcomer.
Not fun work, but very needed !

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.

2 participants