mirror of https://github.com/python/cpython
bpo-46111: Fix unittest tests in optimized mode (GH-30163)
This commit is contained in:
parent
69ef1b5998
commit
95a922b3bb
|
@ -631,6 +631,8 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
|
|||
'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
|
||||
|
|
|
@ -58,9 +58,9 @@ class Test_TestProgram(unittest.TestCase):
|
|||
|
||||
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."""
|
||||
|
|
|
@ -1875,9 +1875,10 @@ class PatchTest(unittest.TestCase):
|
|||
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")
|
||||
|
|
Loading…
Reference in New Issue