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

fix: unit tests for python 3.12 #128

Merged
merged 4 commits into from
Oct 13, 2023
Merged

fix: unit tests for python 3.12 #128

merged 4 commits into from
Oct 13, 2023

Conversation

rsk2
Copy link
Contributor

@rsk2 rsk2 commented Oct 9, 2023

@rsk2 rsk2 changed the title Issue-127: fix test for python 3.12 fix: unit tests for python 3.12 Oct 9, 2023
@rsk2 rsk2 marked this pull request as ready for review October 9, 2023 16:03
@andrii-bodnar
Copy link
Member

Hi @rsk2, the pipeline is failing - https://github.com/crowdin/crowdin-api-client-python/actions/runs/6458990551

could you please take a look?

@andrii-bodnar andrii-bodnar added the hacktoberfest This issue welcomes contributions for Hacktoberfest label Oct 10, 2023
@rsk2
Copy link
Contributor Author

rsk2 commented Oct 10, 2023

@andrii-bodnar, I am not sure how to proceed. There doesn't seem to be any difference between the actual and expected values. Can you please take a look?

@andrii-bodnar
Copy link
Member

@rsk2 it's because of the @deprecated methods. Somehow it wasn't failing before, but after the change, it started to fail on these methods

@rsk2
Copy link
Contributor Author

rsk2 commented Oct 10, 2023

@andrii-bodnar ok. What do you suggest as the solution for this?

@andrii-bodnar
Copy link
Member

andrii-bodnar commented Oct 10, 2023

@rsk2 I'm not sure actually, it requires more investigation

@OmAximani0
Copy link
Contributor

I think it should be properly tested for 3.12 separately on local machine, then we can figure out whats wrong with 3.12

@andrii-bodnar
Copy link
Member

@rsk2 Please try to do something like this to suppress the deprecation warning in tests:

import warnings

def my_test_function():
    # ...

    warnings.filterwarnings('ignore', 'Call to deprecated method generate_simple_cost_estimate_report')

    # Call the deprecated method
    generate_simple_cost_estimate_report()

    # ...

if __name__ == '__main__':
    my_test_function()

@andrii-bodnar
Copy link
Member

or warnings.simplefilter('ignore', category=DeprecationWarning)

@rsk2
Copy link
Contributor Author

rsk2 commented Oct 10, 2023

or warnings.simplefilter('ignore', category=DeprecationWarning)

@andrii-bodnar Ok, I see that you are addressing the deprecation warnings in the tests. But what about the one failed test? Please see screenshot below:
image

@andrii-bodnar
Copy link
Member

@rsk2 I see that the pipeline is almost passing 🙂

Maybe, there is an issue with the test_message test or event with the tested function? Did you try to debug this test locally?

However, the error message you're seeing indicates that the assert_called_once_with call did not find an expected call. This could be due to a mismatch between the call you're asserting and the actual call to template.format. Here are a few things to check:

  • Ensure that the template.format is actually called in your code under test. If it's not called or called multiple times, the assertion will fail.

  • Verify that the argument exc in the assert_called_once_with matches the actual argument passed when calling template.format. The error message suggests that it expected exc=APIException: ..., but it received exc=APIException: ..., indicating that the arguments may not match exactly.

  • Make sure that there are no other mocking or patching that might affect the behavior of the template.format call.

@andrii-bodnar andrii-bodnar self-requested a review October 13, 2023 08:21
@codecov-commenter
Copy link

codecov-commenter commented Oct 13, 2023

Codecov Report

Merging #128 (fc5e2d3) into main (00d0ff2) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #128      +/-   ##
==========================================
+ Coverage   99.19%   99.20%   +0.01%     
==========================================
  Files         146      146              
  Lines        5056     5066      +10     
  Branches      710      710              
==========================================
+ Hits         5015     5025      +10     
  Misses         29       29              
  Partials       12       12              
Files Coverage Δ
..._resources/reports/tests/test_reports_resources.py 100.00% <100.00%> (ø)
crowdin_api/tests/test_exceptions.py 100.00% <100.00%> (ø)

Copy link
Member

@andrii-bodnar andrii-bodnar left a comment

Choose a reason for hiding this comment

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

@rsk2 thank you! 🚀

@andrii-bodnar andrii-bodnar merged commit 9695800 into crowdin:main Oct 13, 2023
6 checks passed
@rsk2
Copy link
Contributor Author

rsk2 commented Oct 13, 2023

@andrii-bodnar thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest This issue welcomes contributions for Hacktoberfest hacktoberfest-accepted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix Unit tests for Python 3.12
4 participants