-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
bpo-45162: Remove many old deprecated unittest features #28268
bpo-45162: Remove many old deprecated unittest features #28268
Conversation
* "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.
See also GH-20400. Should I reopen? |
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. |
I closed it because I got no response, and I had enough to do already with my sqlite3 PR's :)
Absolutely. |
…onGH-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.
…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.
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 <[email protected]>
* 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 <[email protected]> Co-authored-by: Cathy Ouyang <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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
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 <[email protected]>
@tirkarthi, what is the best drop-in replacement for
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? |
https://bugs.python.org/issue45162