Skip to content

[3.9] bpo-46111: Fix unittest tests in optimized mode (GH-30163) #30165

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

Merged
merged 1 commit into from
Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Lib/unittest/test/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,8 @@ def testShortDescriptionWithMultiLineDocstring(self):
'Tests shortDescription() for a method with a longer '
'docstring.')

@unittest.skipIf(sys.flags.optimize >= 2,
"Docstrings are omitted with -O2 and above")
def testShortDescriptionWhitespaceTrimming(self):
"""
Tests shortDescription() whitespace is trimmed, so that the first
Expand Down
4 changes: 2 additions & 2 deletions Lib/unittest/test/test_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def removeTest():

class FooBar(unittest.TestCase):
def testPass(self):
assert True
pass
def testFail(self):
assert False
raise AssertionError

class FooBarLoader(unittest.TestLoader):
"""Test loader that returns a suite containing FooBar."""
Expand Down
3 changes: 2 additions & 1 deletion Lib/unittest/test/testmock/testpatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1875,9 +1875,10 @@ def foo(x=0):
self.assertEqual(foo(), 1)
self.assertEqual(foo(), 0)

orig_doc = foo.__doc__
with patch.object(foo, '__doc__', "FUN"):
self.assertEqual(foo.__doc__, "FUN")
self.assertEqual(foo.__doc__, "TEST")
self.assertEqual(foo.__doc__, orig_doc)

with patch.object(foo, '__module__', "testpatch2"):
self.assertEqual(foo.__module__, "testpatch2")
Expand Down