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

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

Merged

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Sep 10, 2021

  • "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 ambv added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 10, 2021
@bedevere-bot
Copy link

🤖 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 bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 10, 2021
@ambv ambv self-requested a review September 12, 2021 16:18
@erlend-aasland
Copy link
Contributor

See also GH-20400. Should I reopen?

@serhiy-storchaka
Copy link
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.

@erlend-aasland
Copy link
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.

gpshead added a commit to gpshead/cpython that referenced this pull request Jan 26, 2022
…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.
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 <[email protected]>
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 <[email protected]>
Co-authored-by: Cathy Ouyang <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
@jiasli
Copy link
Contributor

jiasli commented Jul 15, 2024

@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?

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