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

chore: Remove usage of deprecated assertDictContainsSubset unittest method. #34330

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

lewisemm
Copy link
Contributor

@lewisemm lewisemm commented Mar 5, 2024

Description

assertDictContainsSubset has been deprecated since Python 3.2 and was removed in Python 3.12.

This PR removes all usage of assertDictContainsSubset and uses the set operator, <=, on dictionary method items() for subset comparisons.

Supporting information

openedx/public-engineering#90

Testing instructions

Please provide detailed step-by-step instructions for testing this change.

Deadline

"None" if there's no rush, or provide a specific date or event (and reason) if there is one.

Other information

Include anything else that will help reviewers and consumers understand the change.

  • Does this change depend on other changes elsewhere?
  • Any special concerns or limitations? For example: deprecations, migrations, security, or accessibility.
  • If your database migration can't be rolled back easily.

@lewisemm lewisemm requested review from a team as code owners March 5, 2024 21:13
@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Mar 5, 2024
@openedx-webhooks
Copy link

openedx-webhooks commented Mar 5, 2024

Thanks for the pull request, @lewisemm! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@jsnwesson jsnwesson added the needs maintainer attention Issue or PR specifically needs the attention of the maintainer. label Mar 6, 2024
@MaxFrank13 MaxFrank13 removed the needs maintainer attention Issue or PR specifically needs the attention of the maintainer. label Mar 7, 2024
@mphilbrick211
Copy link

Hi @lewisemm! Just flagging that there are a few failing tests.

@lewisemm
Copy link
Contributor Author

@mphilbrick211 Thanks for the nudge. Please allow me to convert this to draft as I figure out how to best fix those tests. Also, if you can send help my way that would be greatly appreciated.

@lewisemm lewisemm marked this pull request as draft March 11, 2024 08:01
@mphilbrick211
Copy link

Sounds good, @lewisemm! I'll look into getting you some help!

Comment on lines 864 to 868
self.assertTrue(
duplicated_event.items() <= event_receiver.call_args.kwargs.items()
)
Copy link
Contributor

@ormsbee ormsbee Mar 12, 2024

Choose a reason for hiding this comment

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

I believe you can do:

assert duplicated_event.items() <= event_receiver.call_args.kwargs.items()

Or

self.assertLessEqual(duplicated_event.items(), event_receiver.call_args.kwargs.items())

But trying use assertTrue here will cause pylint to flag it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is perfect. I'll make those changes. Thank you.

@lewisemm
Copy link
Contributor Author

@mphilbrick211 Thanks. I got the help and I'll try to get this ready by end of week.

@lewisemm lewisemm force-pushed the issue-90-assert-dict-contains-subset-deprecated branch from bf190f2 to 062d941 Compare March 15, 2024 10:06
lewisemm added 15 commits March 15, 2024 18:48
Fixes 1 deprecation warning from test runs on the cms-1 shard.
Fixes 1 deprecation warning from cms-2 test runs.
Fix 3 deprecation warnings from test runs on common-with-cms shard.
Fix 7 deprecation warnings from test runs on common-with-lms shard.
Fix 4 deprecation warnings from test runs on lms-1 shard.
Fix 10 deprecation warnings from test runs on lms-3 shard.
Fix 6 deprecation warnings from test runs on lms-4 shard.
Fix 1 deprecation warning from test runs on lms-5 shard.
Fix 77 deprecation warnings from test runs on lms-6 shard.
Fix 10 deprecation warnings from test runs on openedx-1-with-cms shard.
Fix 2 deprecation warnings from test runs on openedx-1-with-lms shard.
Fix 16 deprecation warnings from test runs on openedx-2-with-cms shard.
Fix 30 deprecation warnings from test runs on openedx-2-with-lms shard.
Fix 3 deprecation warnings from test runs on xmodule-with-cms shard.
Use assertLessEqual method to compare dictionary subset overlap.
This replaces the use of `assertTrue(dict1.items() <= dict2.items())`
format which raises pylint errors.
@lewisemm lewisemm force-pushed the issue-90-assert-dict-contains-subset-deprecated branch from 062d941 to e479208 Compare March 15, 2024 15:48
@lewisemm lewisemm marked this pull request as ready for review March 15, 2024 16:17
@mphilbrick211 mphilbrick211 added the waiting for eng review PR is ready for review. Review and merge it, or suggest changes. label Mar 20, 2024
@deborahgu deborahgu removed the request for review from a team April 10, 2024 19:52
@mphilbrick211 mphilbrick211 added needs reviewer assigned PR needs to be (re-)assigned a new reviewer and removed waiting for eng review PR is ready for review. Review and merge it, or suggest changes. labels May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs reviewer assigned PR needs to be (re-)assigned a new reviewer open-source-contribution PR author is not from Axim or 2U
Projects
Status: Ready for Review
Development

Successfully merging this pull request may close these issues.

6 participants