summaryrefslogtreecommitdiffstats
path: root/googletest/test/googletest-catch-exceptions-test.py
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@google.com>2023-01-17 20:15:50 (GMT)
committerCopybara-Service <copybara-worker@google.com>2023-01-17 20:16:29 (GMT)
commitbdb3b0a4939228f28fcb38e786cc29b79db463ab (patch)
tree0c6382619283863973c89e6027e83103190f1cf0 /googletest/test/googletest-catch-exceptions-test.py
parentbba28fa8b2ef2d9725302ab8da0ca7c1a4a81715 (diff)
downloadgoogletest-bdb3b0a4939228f28fcb38e786cc29b79db463ab.zip
googletest-bdb3b0a4939228f28fcb38e786cc29b79db463ab.tar.gz
googletest-bdb3b0a4939228f28fcb38e786cc29b79db463ab.tar.bz2
Replace deprecated python calls
assert_ -> assertTrue/assertFalse/assertIn/assertNotIn assertEquals -> assertEqual PiperOrigin-RevId: 502654909 Change-Id: I25d30095a83c3806606cb80d676b3c979495e6bd
Diffstat (limited to 'googletest/test/googletest-catch-exceptions-test.py')
-rwxr-xr-xgoogletest/test/googletest-catch-exceptions-test.py79
1 files changed, 51 insertions, 28 deletions
diff --git a/googletest/test/googletest-catch-exceptions-test.py b/googletest/test/googletest-catch-exceptions-test.py
index d38d91a..07f1582 100755
--- a/googletest/test/googletest-catch-exceptions-test.py
+++ b/googletest/test/googletest-catch-exceptions-test.py
@@ -81,24 +81,37 @@ if SUPPORTS_SEH_EXCEPTIONS:
class CatchSehExceptionsTest(gtest_test_utils.TestCase):
"""Tests exception-catching behavior."""
-
def TestSehExceptions(self, test_output):
- self.assert_('SEH exception with code 0x2a thrown '
- 'in the test fixture\'s constructor'
- in test_output)
- self.assert_('SEH exception with code 0x2a thrown '
- 'in the test fixture\'s destructor'
- in test_output)
- self.assert_('SEH exception with code 0x2a thrown in SetUpTestSuite()'
- in test_output)
- self.assert_('SEH exception with code 0x2a thrown in TearDownTestSuite()'
- in test_output)
- self.assert_('SEH exception with code 0x2a thrown in SetUp()'
- in test_output)
- self.assert_('SEH exception with code 0x2a thrown in TearDown()'
- in test_output)
- self.assert_('SEH exception with code 0x2a thrown in the test body'
- in test_output)
+ self.assertIn(
+ (
+ 'SEH exception with code 0x2a thrown '
+ "in the test fixture's constructor"
+ ),
+ test_output,
+ )
+ self.assertIn(
+ (
+ 'SEH exception with code 0x2a thrown '
+ "in the test fixture's destructor"
+ ),
+ test_output,
+ )
+ self.assertIn(
+ 'SEH exception with code 0x2a thrown in SetUpTestSuite()', test_output
+ )
+ self.assertIn(
+ 'SEH exception with code 0x2a thrown in TearDownTestSuite()',
+ test_output,
+ )
+ self.assertIn(
+ 'SEH exception with code 0x2a thrown in SetUp()', test_output
+ )
+ self.assertIn(
+ 'SEH exception with code 0x2a thrown in TearDown()', test_output
+ )
+ self.assertIn(
+ 'SEH exception with code 0x2a thrown in the test body', test_output
+ )
def testCatchesSehExceptionsWithCxxExceptionsEnabled(self):
self.TestSehExceptions(EX_BINARY_OUTPUT)
@@ -122,10 +135,14 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
'"Standard C++ exception" thrown '
'in the test fixture\'s constructor' in EX_BINARY_OUTPUT,
EX_BINARY_OUTPUT)
- self.assert_('unexpected' not in EX_BINARY_OUTPUT,
- 'This failure belongs in this test only if '
- '"CxxExceptionInConstructorTest" (no quotes) '
- 'appears on the same line as words "called unexpectedly"')
+ self.assertTrue(
+ 'unexpected' not in EX_BINARY_OUTPUT,
+ (
+ 'This failure belongs in this test only if '
+ '"CxxExceptionInConstructorTest" (no quotes) '
+ 'appears on the same line as words "called unexpectedly"'
+ ),
+ )
if ('CxxExceptionInDestructorTest.ThrowsExceptionInDestructor' in
EX_BINARY_OUTPUT):
@@ -181,10 +198,14 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
self.assertTrue(
'CxxExceptionInSetUpTest::TearDown() '
'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT)
- self.assert_('unexpected' not in EX_BINARY_OUTPUT,
- 'This failure belongs in this test only if '
- '"CxxExceptionInSetUpTest" (no quotes) '
- 'appears on the same line as words "called unexpectedly"')
+ self.assertTrue(
+ 'unexpected' not in EX_BINARY_OUTPUT,
+ (
+ 'This failure belongs in this test only if '
+ '"CxxExceptionInSetUpTest" (no quotes) '
+ 'appears on the same line as words "called unexpectedly"'
+ ),
+ )
def testCatchesCxxExceptionsInTearDown(self):
self.assertTrue(
@@ -227,9 +248,11 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
FITLER_OUT_SEH_TESTS_FLAG],
env=environ).output
- self.assert_('Unhandled C++ exception terminating the program'
- in uncaught_exceptions_ex_binary_output)
- self.assert_('unexpected' not in uncaught_exceptions_ex_binary_output)
+ self.assertIn(
+ 'Unhandled C++ exception terminating the program',
+ uncaught_exceptions_ex_binary_output,
+ )
+ self.assertNotIn('unexpected', uncaught_exceptions_ex_binary_output)
if __name__ == '__main__':