Skip to content

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

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

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!

This repository is currently maintained by @openedx/wg-maintenance-edx-platform.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@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
@sarina
Copy link
Contributor

sarina commented May 13, 2025

@feanil would this PR be helpful for the python 3.12 upgrade?

@feanil
Copy link
Contributor

feanil commented May 13, 2025

yes, we'll have to do it before we move edx-platform to Python 3.12

@sarina
Copy link
Contributor

sarina commented May 13, 2025

If @lewisemm is still willing to contribute this fix, would you @feanil be able to work with them to get it merged?

@feanil
Copy link
Contributor

feanil commented May 13, 2025

Yea, if they can update the PR to resolve conflicts, I'm happy to review and land the PR.

@sarina
Copy link
Contributor

sarina commented May 13, 2025

Awesome, thank you!

@lewisemm - are you still interested in contributing this fix? If so it just needs to be updated to resolve conflicts.

@lewisemm
Copy link
Contributor Author

@sarina - Yes, I'm still interested in contributing this fix.

Hoping I can find some time to go over this within the next one week. Does that work with your release timelines?

@sarina
Copy link
Contributor

sarina commented May 15, 2025

@lewisemm yes that will work well! Please ping @feanil when you're ready for a review.

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.

8 participants