← 返回首页
bpo-45162: Remove many old deprecated unittest features by serhiy-storchaka · Pull Request #28268 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

bpo-45162: Remove many old deprecated unittest features#28268

Merged
serhiy-storchaka merged 5 commits into
python:mainfrom
serhiy-storchaka:unittest-remove-deprecated
Sep 17, 2021
Merged

bpo-45162: Remove many old deprecated unittest features#28268
serhiy-storchaka merged 5 commits into
python:mainfrom
serhiy-storchaka:unittest-remove-deprecated

Conversation

serhiy-storchaka commented Sep 10, 2021
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member
  • "fail*" and "assert*" aliases of TestCase methods.
  • Broken from start TestCase method assertDictContainsSubset().
  • Ignored TestLoader.loadTestsFromModule() parameter use_load_tests.
  • Old alias _TextTestResult of TextTestResult.

https://bugs.python.org/issue45162

* "fail*" and "assert*" aliases of TestCase methods. * Broken from start TestCase method assertDictContainsSubset(). * Ignored TestLoader.loadTestsFromModule() parameter use_load_tests. * Old alias _TextTestResult of TextTestResult.
ambv added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 10, 2021

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @ambv for commit 2d96fb9 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 10, 2021
ambv self-requested a review September 12, 2021 16:18

Copy link
Copy Markdown
Contributor

See also GH-20400. Should I reopen?

Copy link
Copy Markdown
Member Author

I do not know why GH-20400 was closed. Seems there were no objections against it.

But many of these functions are still used in Python tests, so we should first clean up tests from them. Also, we need to research how often they are used in third-party code. The deprecation period can be prolonged if there are many occurrences. All features removed in this PR were deprecated for at least 6 releases.

Copy link
Copy Markdown
Contributor

I do not know why GH-20400 was closed. Seems there were no objections against it.

I closed it because I got no response, and I had enough to do already with my sqlite3 PR's :)

Also, we need to research how often they are used in third-party code. The deprecation period can be prolonged if there are many occurrences. All features removed in this PR were deprecated for at least 6 releases.

Absolutely.

117 hidden items Load more…
gpshead added a commit that referenced this pull request Jan 27, 2022
…30935) Revert "bpo-45162: Remove many old deprecated unittest features (GH-28268)" This reverts commit b0a6ede. We're deferring this change until 3.12 while upstream projects that use the legacy assertion method names are fixed. See the issue for links to the discussion. Many upstream projects now have issues and PRs filed.
arkamar added a commit to arkamar/testresources that referenced this pull request May 31, 2023
This commit replaces deprecated failIf calls with assertFalse in the test_resourced_test_case.py file. The failIf method was removed in Python 3.12 [1-3]. [1] https://docs.python.org/3.12/whatsnew/3.12.html#removed [2] python/cpython#89325 [3] python/cpython#28268 Signed-off-by: Petr Vaněk <arkamar@atlas.cz>
parthea added a commit to googleapis/python-storage that referenced this pull request Nov 29, 2023
cojenco added a commit to googleapis/python-storage that referenced this pull request Dec 1, 2023
* chore(python): Add Python 3.12 Source-Link: googleapis/synthtool@af16e6d Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:bacc3af03bff793a03add584537b36b5644342931ad989e3ba1171d3bd5399f5 * Add trove classifier for python 3.12 * Update contributing.rst, noxfile and constraints to include python 3.12 * remove usage of deprecated assertDictContainsSubset python/cpython#28268 * update tests KMS key settings --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com> Co-authored-by: Cathy Ouyang <cathyo@google.com>
Silvanoc added a commit to linkml/linkml-runtime that referenced this pull request Jan 30, 2024
Unittest method "assertEquals" is deprecated since Python 3.1, but was still present in the code. The deprecated method was removed with bpo-45162 [1] and merged on 3.11. [1]: python/cpython#28268 Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
Silvanoc added a commit to linkml/linkml-runtime that referenced this pull request Jan 30, 2024
Unittest method "assertEquals" is deprecated since Python 3.1, but was still present in the code. The deprecated method was removed with bpo-45162 [1] and merged on 3.11. [1]: python/cpython#28268 Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
Silvanoc added a commit to linkml/linkml-runtime that referenced this pull request Jan 30, 2024
Unittest method "assertEquals" is deprecated since Python 3.1, but was still present in the code. The deprecated method was removed with bpo-45162 [1] and merged on 3.11. [1]: python/cpython#28268 Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
Silvanoc added a commit to linkml/linkml-runtime that referenced this pull request Jan 30, 2024
Unittest method "assertEquals" is deprecated since Python 3.1, but was still present in the code. The deprecated method was removed with bpo-45162 [1] and merged on 3.11. [1]: python/cpython#28268 Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
facebook-github-bot pushed a commit to facebook/openbmc that referenced this pull request Feb 1, 2024
Summary: assertEquals used to be an alias to assertEqual, but seems the aliases were removed: python/cpython#28268 This is causing some tests to fail with ``` ====================================================================== ERROR: test_set_all_fans_and_read (tests.grandcanyon.test_fans.FansTest.test_set_all_fans_and_read) Test setting all fans speed and read to ensure it is the same ---------------------------------------------------------------------- Traceback (most recent call last): File "/run/tests2/common/base_fans_test.py", line 362, in test_set_all_fans_and_read speed = self.get_speed(data) ^^^^^^^^^^^^^^^^^^^^ File "/run/tests2/common/base_fans_test.py", line 287, in get_speed self.assertEquals(num, self.names[m.group(1)], "Bad fan index") ^^^^^^^^^^^^^^^^^ AttributeError: 'FansTest' object has no attribute 'assertEquals'. Did you mean: 'assertEqual'? ``` Test Plan: Test run on grandcanyon ``` $ netcastle --team openbmc --platform grandcanyon Ran 90 tests in 39 mins 54.908 secs [ ERROR] 0 [ FAILED] 0 [ TIMEOUT] 0 [ PASSED] 70 [ SKIPPED] 20 [ OMITTED] 0 [ RETRIED] 0 2024/02/01 02:36:52.896|522087|MainThread|I|abstract_runner: All tests passed! Reviewed By: lsiudut Differential Revision: D53307151 fbshipit-source-id: 163ef91fd883ca607f6bfdb0b10e756015957e74
Silvanoc added a commit to linkml/linkml-runtime that referenced this pull request Feb 13, 2024
Unittest method "assertEquals" is deprecated since Python 3.1, but was still present in the code. The deprecated method was removed with bpo-45162 [1] and merged on 3.11. [1]: python/cpython#28268 Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>

jiasli commented Jul 15, 2024
edited
Loading

Copy link
Copy Markdown
Contributor

@tirkarthi, what is the best drop-in replacement for assertDictContainsSubset? https://stackoverflow.com/a/19221301/2199657 mentioned:

Drop in replacement is to use assertLessEqual and .items() on the dicts.

That is:

- self.assertDictContainsSubset(a, b) + self.assertLessEqual(a.items(), b.items())

twilio/twilio-python#636 and tensorflow/tfx@010e94d adopted different approaches. What is Python's official recommendation?

iQuxLE pushed a commit to linkml/linkml that referenced this pull request Aug 18, 2025
Unittest method "assertEquals" is deprecated since Python 3.1, but was still present in the code. The deprecated method was removed with bpo-45162 [1] and merged on 3.11. [1]: python/cpython#28268 Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
parthea added a commit to googleapis/google-cloud-python that referenced this pull request Mar 9, 2026
* chore(python): Add Python 3.12 Source-Link: googleapis/synthtool@af16e6d Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:bacc3af03bff793a03add584537b36b5644342931ad989e3ba1171d3bd5399f5 * Add trove classifier for python 3.12 * Update contributing.rst, noxfile and constraints to include python 3.12 * remove usage of deprecated assertDictContainsSubset python/cpython#28268 * update tests KMS key settings --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com> Co-authored-by: Cathy Ouyang <cathyo@google.com>
chalmerlowe pushed a commit to GoogleCloudPlatform/python-docs-samples that referenced this pull request Apr 7, 2026
* chore(python): Add Python 3.12 Source-Link: googleapis/synthtool@af16e6d Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:bacc3af03bff793a03add584537b36b5644342931ad989e3ba1171d3bd5399f5 * Add trove classifier for python 3.12 * Update contributing.rst, noxfile and constraints to include python 3.12 * remove usage of deprecated assertDictContainsSubset python/cpython#28268 * update tests KMS key settings --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com> Co-authored-by: Cathy Ouyang <cathyo@google.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

Footer

© 2026 GitHub, Inc.