-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Fixed several assertTrue() that were intended to be assertEqual(). #8191
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
Conversation
Lib/ctypes/test/test_as_parameter.py
Outdated
@@ -24,7 +24,7 @@ def test_wchar_parm(self): | |||
f.argtypes = [c_byte, c_wchar, c_int, c_long, c_float, c_double] | |||
result = f(self.wrap(1), self.wrap("x"), self.wrap(3), self.wrap(4), self.wrap(5.0), self.wrap(6.0)) | |||
self.assertEqual(result, 139) | |||
self.assertTrue(type(result), int) | |||
self.assertEqual(type(result), int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe even assertIs
?
Lib/test/test_warnings/__init__.py
Outdated
@@ -149,9 +149,9 @@ def test_always(self): | |||
self.module.filterwarnings("always", category=UserWarning) | |||
message = "FilterTests.test_always" | |||
self.module.warn(message, UserWarning) | |||
self.assertTrue(message, w[-1].message) | |||
self.assertEqual(message, w[-1].message.args[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are other flaws in this test, due to which the second assertion doesn't have effect. Rewrite the test as:
def test_always(self):
with original_warnings.catch_warnings(record=True,
module=self.module) as w:
self.module.resetwarnings()
self.module.filterwarnings("always", category=UserWarning)
message = "FilterTests.test_always"
def f():
self.module.warn(message, UserWarning)
f()
self.assertEqual(len(w), 1)
self.assertEqual(w[-1].message.args[0], message)
f()
self.assertEqual(len(w), 2)
self.assertEqual(w[-1].message.args[0], message)
Good catch! |
Thanks @sir-sigurd for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6, 3.7. |
GH-8200 is a backport of this pull request to the 3.7 branch. |
Sorry, @sir-sigurd and @serhiy-storchaka, I could not cleanly backport this to |
…ythonGH-8191) Fixed also testing the "always" warning filter. (cherry picked from commit b796e7d) Co-authored-by: Sergey Fedoseev <[email protected]>
GH-8201 is a backport of this pull request to the 3.6 branch. |
…ythonGH-8191) Fixed also testing the "always" warning filter. (cherry picked from commit b796e7d) Co-authored-by: Sergey Fedoseev <[email protected]>
…H-8191) Fixed also testing the "always" warning filter. (cherry picked from commit b796e7d) Co-authored-by: Sergey Fedoseev <[email protected]>
…H-8191) Fixed also testing the "always" warning filter. (cherry picked from commit b796e7d) Co-authored-by: Sergey Fedoseev <[email protected]>
…(). (pythonGH-8191) Fixed also testing the "always" warning filter.. (cherry picked from commit b796e7d) Co-authored-by: Sergey Fedoseev <[email protected]>
GH-8202 is a backport of this pull request to the 2.7 branch. |
…(). (GH-8191) (GH-8202) Fixed also testing the "always" warning filter. (cherry picked from commit b796e7d) Co-authored-by: Sergey Fedoseev <[email protected]>
No description provided.