Skip to content

Refactor test_scale_to function - continue to establish good practices #255

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 8 commits into from
Dec 20, 2024

Conversation

bobleesj
Copy link
Contributor

@bobleesj bobleesj commented Dec 19, 2024

The goal of this PR is to demonstrate how to refactor a specific test function.

  • Use variable names that are concise, clear, yet does not lose info
  • Correctly use @pytest.mark.parametrize to init objects
  • Differentiate info vs warning messages for end-users

Copy link

codecov bot commented Dec 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (2bc765f) to head (206d39d).
Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #255   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            8         8           
  Lines          380       378    -2     
=========================================
- Hits           380       378    -2     
Files with missing lines Coverage Δ
tests/test_diffraction_objects.py 100.00% <100.00%> (ø)

@bobleesj
Copy link
Contributor Author

@sbillinge ready for review - @yucongalicechen continuing to refactor test functions for future maintenance.

Copy link
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

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

looks great....but please see inline.

inf_output_wmsg = (
"INFO: The largest output value in the array is infinite. This is allowed, but it will not be plotted."
)
inf_output_wmsg = "The largest output value in the array is infinite. This is allowed, but it will not be plotted."
Copy link
Contributor

Choose a reason for hiding this comment

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

This is supposed to be an info not a warning. I think we want INFO and change wmsg to imsg in the name. Make sure it is a print and not a warning.warn in the code.

The group standard could be that a warning means that something is wrong, albeit not error generating.

Here it is "expected" that we will have infinities sometimes and we want to handle them if possible. So nothing is wrong but we want the user to alerted so they understand any magic.

Not sure if that all makes sense.

},
False,
),
( # One without wavelnegth, expect inequality
Copy link
Contributor Author

Choose a reason for hiding this comment

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

quick note to myself - fix typo

@sbillinge
Copy link
Contributor

@bobleesj LGTM. I am happy to merge whenever you are ready. Great improvement. Not sure if you did the high level scoping sttement. I have to board my flight though....

@bobleesj
Copy link
Contributor Author

@bobleesj LGTM. I am happy to merge whenever you are ready. Great improvement. Not sure if you did the high level scoping sttement. I have to board my flight though....

@sbillinge I will take some time to internalize the comments and make new commits later today. Thanks a lot! Safe travels to Africa.

@bobleesj
Copy link
Contributor Author

bobleesj commented Dec 20, 2024

@sbillinge Ready for review - the last commit is just quick fix from UC to Case as noted and adding "No news added".

For higher-level ones, I created separate issues: 1) how to enforce BG members to define testing scope before writing one 2) grouping test cases 3) review warning/info/error runtime error messages

@sbillinge sbillinge merged commit 8eaf5d7 into diffpy:main Dec 20, 2024
5 checks passed
@bobleesj bobleesj deleted the pytest-warning branch December 20, 2024 23:36
@bobleesj
Copy link
Contributor Author

Noted the additional commits made with higher-level test comments.

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