830 lines
36 KiB
Diff
830 lines
36 KiB
Diff
From bdb3b0a4939228f28fcb38e786cc29b79db463ab Mon Sep 17 00:00:00 2001
|
|
From: Tom Hughes <tomhughes@google.com>
|
|
Date: Tue, 17 Jan 2023 12:15:50 -0800
|
|
Subject: [PATCH] Replace deprecated python calls
|
|
|
|
assert_ -> assertTrue/assertFalse/assertIn/assertNotIn
|
|
assertEquals -> assertEqual
|
|
|
|
PiperOrigin-RevId: 502654909
|
|
Change-Id: I25d30095a83c3806606cb80d676b3c979495e6bd
|
|
---
|
|
CONTRIBUTING.md | 2 +-
|
|
googlemock/test/gmock_leak_test.py | 4 +-
|
|
.../googletest-break-on-failure-unittest.py | 2 +-
|
|
.../test/googletest-catch-exceptions-test.py | 79 ++++++++++++-------
|
|
googletest/test/googletest-color-test.py | 68 ++++++++--------
|
|
googletest/test/googletest-filter-unittest.py | 26 +++---
|
|
.../test/googletest-json-outfiles-test.py | 10 ++-
|
|
.../test/googletest-json-output-unittest.py | 38 +++++----
|
|
.../test/googletest-list-tests-unittest.py | 23 ++++--
|
|
googletest/test/googletest-shuffle-test.py | 76 +++++++++++-------
|
|
.../test/googletest-throw-on-failure-test.py | 2 +-
|
|
googletest/test/gtest_testbridge_test.py | 2 +-
|
|
googletest/test/gtest_xml_outfiles_test.py | 10 ++-
|
|
googletest/test/gtest_xml_output_unittest.py | 38 +++++----
|
|
googletest/test/gtest_xml_test_utils.py | 78 +++++++++++-------
|
|
15 files changed, 272 insertions(+), 186 deletions(-)
|
|
|
|
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
|
|
index de14c815..423b0675 100644
|
|
--- a/CONTRIBUTING.md
|
|
+++ b/CONTRIBUTING.md
|
|
@@ -88,7 +88,7 @@ check your formatting.
|
|
If you plan to contribute a patch, you need to build Google Test, Google Mock,
|
|
and their own tests from a git checkout, which has further requirements:
|
|
|
|
-* [Python](https://www.python.org/) v2.3 or newer (for running some of the
|
|
+* [Python](https://www.python.org/) v3.6 or newer (for running some of the
|
|
tests and re-generating certain source files from templates)
|
|
* [CMake](https://cmake.org/) v2.8.12 or newer
|
|
|
|
diff --git a/googlemock/test/gmock_leak_test.py b/googlemock/test/gmock_leak_test.py
|
|
index 4f41c7bb..9d142d34 100755
|
|
--- a/googlemock/test/gmock_leak_test.py
|
|
+++ b/googlemock/test/gmock_leak_test.py
|
|
@@ -62,12 +62,12 @@ class GMockLeakTest(gmock_test_utils.TestCase):
|
|
env=environ).exit_code)
|
|
|
|
def testDoesNotCatchLeakedMockWhenDisabled(self):
|
|
- self.assertEquals(
|
|
+ self.assertEqual(
|
|
0,
|
|
gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL +
|
|
['--gmock_catch_leaked_mocks=0'],
|
|
env=environ).exit_code)
|
|
- self.assertEquals(
|
|
+ self.assertEqual(
|
|
0,
|
|
gmock_test_utils.Subprocess(TEST_WITH_ON_CALL +
|
|
['--gmock_catch_leaked_mocks=0'],
|
|
diff --git a/googletest/test/googletest-break-on-failure-unittest.py b/googletest/test/googletest-break-on-failure-unittest.py
|
|
index 4eafba3e..c5c0b157 100755
|
|
--- a/googletest/test/googletest-break-on-failure-unittest.py
|
|
+++ b/googletest/test/googletest-break-on-failure-unittest.py
|
|
@@ -135,7 +135,7 @@ class GTestBreakOnFailureUnitTest(gtest_test_utils.TestCase):
|
|
msg = ('when %s%s, an assertion failure in "%s" %s cause a seg-fault.' %
|
|
(BREAK_ON_FAILURE_ENV_VAR, env_var_value_msg, ' '.join(command),
|
|
should_or_not))
|
|
- self.assert_(has_seg_fault == expect_seg_fault, msg)
|
|
+ self.assertTrue(has_seg_fault == expect_seg_fault, msg)
|
|
|
|
def testDefaultBehavior(self):
|
|
"""Tests the behavior of the default mode."""
|
|
diff --git a/googletest/test/googletest-catch-exceptions-test.py b/googletest/test/googletest-catch-exceptions-test.py
|
|
index d38d91a6..07f15826 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__':
|
|
diff --git a/googletest/test/googletest-color-test.py b/googletest/test/googletest-color-test.py
|
|
index f08edf70..32dafccc 100755
|
|
--- a/googletest/test/googletest-color-test.py
|
|
+++ b/googletest/test/googletest-color-test.py
|
|
@@ -69,59 +69,59 @@ class GTestColorTest(gtest_test_utils.TestCase):
|
|
"""Tests the case when there's neither GTEST_COLOR nor --gtest_color."""
|
|
|
|
if not IS_WINDOWS:
|
|
- self.assert_(not UsesColor('dumb', None, None))
|
|
- self.assert_(not UsesColor('emacs', None, None))
|
|
- self.assert_(not UsesColor('xterm-mono', None, None))
|
|
- self.assert_(not UsesColor('unknown', None, None))
|
|
- self.assert_(not UsesColor(None, None, None))
|
|
- self.assert_(UsesColor('linux', None, None))
|
|
- self.assert_(UsesColor('cygwin', None, None))
|
|
- self.assert_(UsesColor('xterm', None, None))
|
|
- self.assert_(UsesColor('xterm-color', None, None))
|
|
- self.assert_(UsesColor('xterm-kitty', None, None))
|
|
- self.assert_(UsesColor('xterm-256color', None, None))
|
|
+ self.assertTrue(not UsesColor('dumb', None, None))
|
|
+ self.assertTrue(not UsesColor('emacs', None, None))
|
|
+ self.assertTrue(not UsesColor('xterm-mono', None, None))
|
|
+ self.assertTrue(not UsesColor('unknown', None, None))
|
|
+ self.assertTrue(not UsesColor(None, None, None))
|
|
+ self.assertTrue(UsesColor('linux', None, None))
|
|
+ self.assertTrue(UsesColor('cygwin', None, None))
|
|
+ self.assertTrue(UsesColor('xterm', None, None))
|
|
+ self.assertTrue(UsesColor('xterm-color', None, None))
|
|
+ self.assertTrue(UsesColor('xterm-kitty', None, None))
|
|
+ self.assertTrue(UsesColor('xterm-256color', None, None))
|
|
|
|
def testFlagOnly(self):
|
|
"""Tests the case when there's --gtest_color but not GTEST_COLOR."""
|
|
|
|
- self.assert_(not UsesColor('dumb', None, 'no'))
|
|
- self.assert_(not UsesColor('xterm-color', None, 'no'))
|
|
+ self.assertTrue(not UsesColor('dumb', None, 'no'))
|
|
+ self.assertTrue(not UsesColor('xterm-color', None, 'no'))
|
|
if not IS_WINDOWS:
|
|
- self.assert_(not UsesColor('emacs', None, 'auto'))
|
|
- self.assert_(UsesColor('xterm', None, 'auto'))
|
|
- self.assert_(UsesColor('dumb', None, 'yes'))
|
|
- self.assert_(UsesColor('xterm', None, 'yes'))
|
|
+ self.assertTrue(not UsesColor('emacs', None, 'auto'))
|
|
+ self.assertTrue(UsesColor('xterm', None, 'auto'))
|
|
+ self.assertTrue(UsesColor('dumb', None, 'yes'))
|
|
+ self.assertTrue(UsesColor('xterm', None, 'yes'))
|
|
|
|
def testEnvVarOnly(self):
|
|
"""Tests the case when there's GTEST_COLOR but not --gtest_color."""
|
|
|
|
- self.assert_(not UsesColor('dumb', 'no', None))
|
|
- self.assert_(not UsesColor('xterm-color', 'no', None))
|
|
+ self.assertTrue(not UsesColor('dumb', 'no', None))
|
|
+ self.assertTrue(not UsesColor('xterm-color', 'no', None))
|
|
if not IS_WINDOWS:
|
|
- self.assert_(not UsesColor('dumb', 'auto', None))
|
|
- self.assert_(UsesColor('xterm-color', 'auto', None))
|
|
- self.assert_(UsesColor('dumb', 'yes', None))
|
|
- self.assert_(UsesColor('xterm-color', 'yes', None))
|
|
+ self.assertTrue(not UsesColor('dumb', 'auto', None))
|
|
+ self.assertTrue(UsesColor('xterm-color', 'auto', None))
|
|
+ self.assertTrue(UsesColor('dumb', 'yes', None))
|
|
+ self.assertTrue(UsesColor('xterm-color', 'yes', None))
|
|
|
|
def testEnvVarAndFlag(self):
|
|
"""Tests the case when there are both GTEST_COLOR and --gtest_color."""
|
|
|
|
- self.assert_(not UsesColor('xterm-color', 'no', 'no'))
|
|
- self.assert_(UsesColor('dumb', 'no', 'yes'))
|
|
- self.assert_(UsesColor('xterm-color', 'no', 'auto'))
|
|
+ self.assertTrue(not UsesColor('xterm-color', 'no', 'no'))
|
|
+ self.assertTrue(UsesColor('dumb', 'no', 'yes'))
|
|
+ self.assertTrue(UsesColor('xterm-color', 'no', 'auto'))
|
|
|
|
def testAliasesOfYesAndNo(self):
|
|
"""Tests using aliases in specifying --gtest_color."""
|
|
|
|
- self.assert_(UsesColor('dumb', None, 'true'))
|
|
- self.assert_(UsesColor('dumb', None, 'YES'))
|
|
- self.assert_(UsesColor('dumb', None, 'T'))
|
|
- self.assert_(UsesColor('dumb', None, '1'))
|
|
+ self.assertTrue(UsesColor('dumb', None, 'true'))
|
|
+ self.assertTrue(UsesColor('dumb', None, 'YES'))
|
|
+ self.assertTrue(UsesColor('dumb', None, 'T'))
|
|
+ self.assertTrue(UsesColor('dumb', None, '1'))
|
|
|
|
- self.assert_(not UsesColor('xterm', None, 'f'))
|
|
- self.assert_(not UsesColor('xterm', None, 'false'))
|
|
- self.assert_(not UsesColor('xterm', None, '0'))
|
|
- self.assert_(not UsesColor('xterm', None, 'unknown'))
|
|
+ self.assertTrue(not UsesColor('xterm', None, 'f'))
|
|
+ self.assertTrue(not UsesColor('xterm', None, 'false'))
|
|
+ self.assertTrue(not UsesColor('xterm', None, '0'))
|
|
+ self.assertTrue(not UsesColor('xterm', None, 'unknown'))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
diff --git a/googletest/test/googletest-filter-unittest.py b/googletest/test/googletest-filter-unittest.py
|
|
index 2c4a1b18..02fd1dfb 100755
|
|
--- a/googletest/test/googletest-filter-unittest.py
|
|
+++ b/googletest/test/googletest-filter-unittest.py
|
|
@@ -250,10 +250,10 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
|
|
"""Asserts that two sets are equal."""
|
|
|
|
for elem in lhs:
|
|
- self.assert_(elem in rhs, '%s in %s' % (elem, rhs))
|
|
+ self.assertTrue(elem in rhs, '%s in %s' % (elem, rhs))
|
|
|
|
for elem in rhs:
|
|
- self.assert_(elem in lhs, '%s in %s' % (elem, lhs))
|
|
+ self.assertTrue(elem in lhs, '%s in %s' % (elem, lhs))
|
|
|
|
def AssertPartitionIsValid(self, set_var, list_of_sets):
|
|
"""Asserts that list_of_sets is a valid partition of set_var."""
|
|
@@ -595,13 +595,13 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
|
|
|
|
shard_status_file = os.path.join(gtest_test_utils.GetTempDir(),
|
|
'shard_status_file')
|
|
- self.assert_(not os.path.exists(shard_status_file))
|
|
+ self.assertTrue(not os.path.exists(shard_status_file))
|
|
|
|
extra_env = {SHARD_STATUS_FILE_ENV_VAR: shard_status_file}
|
|
try:
|
|
InvokeWithModifiedEnv(extra_env, RunAndReturnOutput)
|
|
finally:
|
|
- self.assert_(os.path.exists(shard_status_file))
|
|
+ self.assertTrue(os.path.exists(shard_status_file))
|
|
os.remove(shard_status_file)
|
|
|
|
def testShardStatusFileIsCreatedWithListTests(self):
|
|
@@ -609,7 +609,7 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
|
|
|
|
shard_status_file = os.path.join(gtest_test_utils.GetTempDir(),
|
|
'shard_status_file2')
|
|
- self.assert_(not os.path.exists(shard_status_file))
|
|
+ self.assertTrue(not os.path.exists(shard_status_file))
|
|
|
|
extra_env = {SHARD_STATUS_FILE_ENV_VAR: shard_status_file}
|
|
try:
|
|
@@ -619,12 +619,16 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
|
|
finally:
|
|
# This assertion ensures that Google Test enumerated the tests as
|
|
# opposed to running them.
|
|
- self.assert_('[==========]' not in output,
|
|
- 'Unexpected output during test enumeration.\n'
|
|
- 'Please ensure that LIST_TESTS_FLAG is assigned the\n'
|
|
- 'correct flag value for listing Google Test tests.')
|
|
-
|
|
- self.assert_(os.path.exists(shard_status_file))
|
|
+ self.assertTrue(
|
|
+ '[==========]' not in output,
|
|
+ (
|
|
+ 'Unexpected output during test enumeration.\n'
|
|
+ 'Please ensure that LIST_TESTS_FLAG is assigned the\n'
|
|
+ 'correct flag value for listing Google Test tests.'
|
|
+ ),
|
|
+ )
|
|
+
|
|
+ self.assertTrue(os.path.exists(shard_status_file))
|
|
os.remove(shard_status_file)
|
|
|
|
def testDisabledBanner(self):
|
|
diff --git a/googletest/test/googletest-json-outfiles-test.py b/googletest/test/googletest-json-outfiles-test.py
|
|
index 179283b8..3abf355d 100644
|
|
--- a/googletest/test/googletest-json-outfiles-test.py
|
|
+++ b/googletest/test/googletest-json-outfiles-test.py
|
|
@@ -171,15 +171,17 @@ class GTestJsonOutFilesTest(gtest_test_utils.TestCase):
|
|
command = [gtest_prog_path, '--gtest_output=json:%s' % self.output_dir_]
|
|
p = gtest_test_utils.Subprocess(command,
|
|
working_dir=gtest_test_utils.GetTempDir())
|
|
- self.assert_(p.exited)
|
|
- self.assertEquals(0, p.exit_code)
|
|
+ self.assertTrue(p.exited)
|
|
+ self.assertEqual(0, p.exit_code)
|
|
|
|
output_file_name1 = test_name + '.json'
|
|
output_file1 = os.path.join(self.output_dir_, output_file_name1)
|
|
output_file_name2 = 'lt-' + output_file_name1
|
|
output_file2 = os.path.join(self.output_dir_, output_file_name2)
|
|
- self.assert_(os.path.isfile(output_file1) or os.path.isfile(output_file2),
|
|
- output_file1)
|
|
+ self.assertTrue(
|
|
+ os.path.isfile(output_file1) or os.path.isfile(output_file2),
|
|
+ output_file1,
|
|
+ )
|
|
|
|
if os.path.isfile(output_file1):
|
|
with open(output_file1) as f:
|
|
diff --git a/googletest/test/googletest-json-output-unittest.py b/googletest/test/googletest-json-output-unittest.py
|
|
index e0fbe465..c8915b2f 100644
|
|
--- a/googletest/test/googletest-json-output-unittest.py
|
|
+++ b/googletest/test/googletest-json-output-unittest.py
|
|
@@ -806,9 +806,9 @@ class GTestJsonOutputUnitTest(gtest_test_utils.TestCase):
|
|
p = gtest_test_utils.Subprocess(
|
|
[gtest_prog_path, '%s=json' % GTEST_OUTPUT_FLAG],
|
|
working_dir=gtest_test_utils.GetTempDir())
|
|
- self.assert_(p.exited)
|
|
- self.assertEquals(0, p.exit_code)
|
|
- self.assert_(os.path.isfile(output_file))
|
|
+ self.assertTrue(p.exited)
|
|
+ self.assertEqual(0, p.exit_code)
|
|
+ self.assertTrue(os.path.isfile(output_file))
|
|
|
|
def testSuppressedJsonOutput(self):
|
|
"""Verifies that no JSON output is generated.
|
|
@@ -832,13 +832,15 @@ class GTestJsonOutputUnitTest(gtest_test_utils.TestCase):
|
|
p.terminated_by_signal,
|
|
'%s was killed by signal %d' % (GTEST_PROGRAM_NAME, p.signal))
|
|
else:
|
|
- self.assert_(p.exited)
|
|
- self.assertEquals(1, p.exit_code,
|
|
- "'%s' exited with code %s, which doesn't match "
|
|
- 'the expected exit code %s.'
|
|
- % (command, p.exit_code, 1))
|
|
+ self.assertTrue(p.exited)
|
|
+ self.assertEqual(
|
|
+ 1,
|
|
+ p.exit_code,
|
|
+ "'%s' exited with code %s, which doesn't match "
|
|
+ 'the expected exit code %s.' % (command, p.exit_code, 1),
|
|
+ )
|
|
|
|
- self.assert_(not os.path.isfile(json_path))
|
|
+ self.assertTrue(not os.path.isfile(json_path))
|
|
|
|
def testFilteredTestJsonOutput(self):
|
|
"""Verifies JSON output when a filter is applied.
|
|
@@ -870,14 +872,18 @@ class GTestJsonOutputUnitTest(gtest_test_utils.TestCase):
|
|
)
|
|
p = gtest_test_utils.Subprocess(command)
|
|
if p.terminated_by_signal:
|
|
- self.assert_(False,
|
|
- '%s was killed by signal %d' % (gtest_prog_name, p.signal))
|
|
+ self.assertTrue(
|
|
+ False, '%s was killed by signal %d' % (gtest_prog_name, p.signal)
|
|
+ )
|
|
else:
|
|
- self.assert_(p.exited)
|
|
- self.assertEquals(expected_exit_code, p.exit_code,
|
|
- "'%s' exited with code %s, which doesn't match "
|
|
- 'the expected exit code %s.'
|
|
- % (command, p.exit_code, expected_exit_code))
|
|
+ self.assertTrue(p.exited)
|
|
+ self.assertEqual(
|
|
+ expected_exit_code,
|
|
+ p.exit_code,
|
|
+ "'%s' exited with code %s, which doesn't match "
|
|
+ 'the expected exit code %s.'
|
|
+ % (command, p.exit_code, expected_exit_code),
|
|
+ )
|
|
with open(json_path) as f:
|
|
actual = json.load(f)
|
|
return actual
|
|
diff --git a/googletest/test/googletest-list-tests-unittest.py b/googletest/test/googletest-list-tests-unittest.py
|
|
index 9d56883d..485150dd 100755
|
|
--- a/googletest/test/googletest-list-tests-unittest.py
|
|
+++ b/googletest/test/googletest-list-tests-unittest.py
|
|
@@ -156,17 +156,24 @@ class GTestListTestsUnitTest(gtest_test_utils.TestCase):
|
|
output = Run(args)
|
|
|
|
if expected_output_re:
|
|
- self.assert_(
|
|
+ self.assertTrue(
|
|
expected_output_re.match(output),
|
|
- ('when %s is %s, the output of "%s" is "%s",\n'
|
|
- 'which does not match regex "%s"' %
|
|
- (LIST_TESTS_FLAG, flag_expression, ' '.join(args), output,
|
|
- expected_output_re.pattern)))
|
|
+ 'when %s is %s, the output of "%s" is "%s",\n'
|
|
+ 'which does not match regex "%s"'
|
|
+ % (
|
|
+ LIST_TESTS_FLAG,
|
|
+ flag_expression,
|
|
+ ' '.join(args),
|
|
+ output,
|
|
+ expected_output_re.pattern,
|
|
+ ),
|
|
+ )
|
|
else:
|
|
- self.assert_(
|
|
+ self.assertTrue(
|
|
not EXPECTED_OUTPUT_NO_FILTER_RE.match(output),
|
|
- ('when %s is %s, the output of "%s" is "%s"'%
|
|
- (LIST_TESTS_FLAG, flag_expression, ' '.join(args), output)))
|
|
+ 'when %s is %s, the output of "%s" is "%s"'
|
|
+ % (LIST_TESTS_FLAG, flag_expression, ' '.join(args), output),
|
|
+ )
|
|
|
|
def testDefaultBehavior(self):
|
|
"""Tests the behavior of the default mode."""
|
|
diff --git a/googletest/test/googletest-shuffle-test.py b/googletest/test/googletest-shuffle-test.py
|
|
index 9d2adc12..61e25932 100755
|
|
--- a/googletest/test/googletest-shuffle-test.py
|
|
+++ b/googletest/test/googletest-shuffle-test.py
|
|
@@ -177,25 +177,34 @@ class GTestShuffleUnitTest(gtest_test_utils.TestCase):
|
|
self.assertEqual(len(SHARDED_TESTS), len(SHUFFLED_SHARDED_TESTS))
|
|
|
|
def testShuffleChangesTestOrder(self):
|
|
- self.assert_(SHUFFLED_ALL_TESTS != ALL_TESTS, SHUFFLED_ALL_TESTS)
|
|
- self.assert_(SHUFFLED_ACTIVE_TESTS != ACTIVE_TESTS, SHUFFLED_ACTIVE_TESTS)
|
|
- self.assert_(SHUFFLED_FILTERED_TESTS != FILTERED_TESTS,
|
|
- SHUFFLED_FILTERED_TESTS)
|
|
- self.assert_(SHUFFLED_SHARDED_TESTS != SHARDED_TESTS,
|
|
- SHUFFLED_SHARDED_TESTS)
|
|
+ self.assertTrue(SHUFFLED_ALL_TESTS != ALL_TESTS, SHUFFLED_ALL_TESTS)
|
|
+ self.assertTrue(
|
|
+ SHUFFLED_ACTIVE_TESTS != ACTIVE_TESTS, SHUFFLED_ACTIVE_TESTS
|
|
+ )
|
|
+ self.assertTrue(
|
|
+ SHUFFLED_FILTERED_TESTS != FILTERED_TESTS, SHUFFLED_FILTERED_TESTS
|
|
+ )
|
|
+ self.assertTrue(
|
|
+ SHUFFLED_SHARDED_TESTS != SHARDED_TESTS, SHUFFLED_SHARDED_TESTS
|
|
+ )
|
|
|
|
def testShuffleChangesTestCaseOrder(self):
|
|
- self.assert_(GetTestCases(SHUFFLED_ALL_TESTS) != GetTestCases(ALL_TESTS),
|
|
- GetTestCases(SHUFFLED_ALL_TESTS))
|
|
- self.assert_(
|
|
+ self.assertTrue(
|
|
+ GetTestCases(SHUFFLED_ALL_TESTS) != GetTestCases(ALL_TESTS),
|
|
+ GetTestCases(SHUFFLED_ALL_TESTS),
|
|
+ )
|
|
+ self.assertTrue(
|
|
GetTestCases(SHUFFLED_ACTIVE_TESTS) != GetTestCases(ACTIVE_TESTS),
|
|
- GetTestCases(SHUFFLED_ACTIVE_TESTS))
|
|
- self.assert_(
|
|
+ GetTestCases(SHUFFLED_ACTIVE_TESTS),
|
|
+ )
|
|
+ self.assertTrue(
|
|
GetTestCases(SHUFFLED_FILTERED_TESTS) != GetTestCases(FILTERED_TESTS),
|
|
- GetTestCases(SHUFFLED_FILTERED_TESTS))
|
|
- self.assert_(
|
|
+ GetTestCases(SHUFFLED_FILTERED_TESTS),
|
|
+ )
|
|
+ self.assertTrue(
|
|
GetTestCases(SHUFFLED_SHARDED_TESTS) != GetTestCases(SHARDED_TESTS),
|
|
- GetTestCases(SHUFFLED_SHARDED_TESTS))
|
|
+ GetTestCases(SHUFFLED_SHARDED_TESTS),
|
|
+ )
|
|
|
|
def testShuffleDoesNotRepeatTest(self):
|
|
for test in SHUFFLED_ALL_TESTS:
|
|
@@ -213,30 +222,34 @@ class GTestShuffleUnitTest(gtest_test_utils.TestCase):
|
|
|
|
def testShuffleDoesNotCreateNewTest(self):
|
|
for test in SHUFFLED_ALL_TESTS:
|
|
- self.assert_(test in ALL_TESTS, '%s is an invalid test' % (test,))
|
|
+ self.assertTrue(test in ALL_TESTS, '%s is an invalid test' % (test,))
|
|
for test in SHUFFLED_ACTIVE_TESTS:
|
|
- self.assert_(test in ACTIVE_TESTS, '%s is an invalid test' % (test,))
|
|
+ self.assertTrue(test in ACTIVE_TESTS, '%s is an invalid test' % (test,))
|
|
for test in SHUFFLED_FILTERED_TESTS:
|
|
- self.assert_(test in FILTERED_TESTS, '%s is an invalid test' % (test,))
|
|
+ self.assertTrue(test in FILTERED_TESTS, '%s is an invalid test' % (test,))
|
|
for test in SHUFFLED_SHARDED_TESTS:
|
|
- self.assert_(test in SHARDED_TESTS, '%s is an invalid test' % (test,))
|
|
+ self.assertTrue(test in SHARDED_TESTS, '%s is an invalid test' % (test,))
|
|
|
|
def testShuffleIncludesAllTests(self):
|
|
for test in ALL_TESTS:
|
|
- self.assert_(test in SHUFFLED_ALL_TESTS, '%s is missing' % (test,))
|
|
+ self.assertTrue(test in SHUFFLED_ALL_TESTS, '%s is missing' % (test,))
|
|
for test in ACTIVE_TESTS:
|
|
- self.assert_(test in SHUFFLED_ACTIVE_TESTS, '%s is missing' % (test,))
|
|
+ self.assertTrue(test in SHUFFLED_ACTIVE_TESTS, '%s is missing' % (test,))
|
|
for test in FILTERED_TESTS:
|
|
- self.assert_(test in SHUFFLED_FILTERED_TESTS, '%s is missing' % (test,))
|
|
+ self.assertTrue(
|
|
+ test in SHUFFLED_FILTERED_TESTS, '%s is missing' % (test,)
|
|
+ )
|
|
for test in SHARDED_TESTS:
|
|
- self.assert_(test in SHUFFLED_SHARDED_TESTS, '%s is missing' % (test,))
|
|
+ self.assertTrue(test in SHUFFLED_SHARDED_TESTS, '%s is missing' % (test,))
|
|
|
|
def testShuffleLeavesDeathTestsAtFront(self):
|
|
non_death_test_found = False
|
|
for test in SHUFFLED_ACTIVE_TESTS:
|
|
if 'DeathTest.' in test:
|
|
- self.assert_(not non_death_test_found,
|
|
- '%s appears after a non-death test' % (test,))
|
|
+ self.assertTrue(
|
|
+ not non_death_test_found,
|
|
+ '%s appears after a non-death test' % (test,),
|
|
+ )
|
|
else:
|
|
non_death_test_found = True
|
|
|
|
@@ -293,12 +306,15 @@ class GTestShuffleUnitTest(gtest_test_utils.TestCase):
|
|
GetTestsForAllIterations(
|
|
{}, [ShuffleFlag(), RandomSeedFlag(1), RepeatFlag(3)]))
|
|
|
|
- self.assert_(tests_in_iteration1 != tests_in_iteration2,
|
|
- tests_in_iteration1)
|
|
- self.assert_(tests_in_iteration1 != tests_in_iteration3,
|
|
- tests_in_iteration1)
|
|
- self.assert_(tests_in_iteration2 != tests_in_iteration3,
|
|
- tests_in_iteration2)
|
|
+ self.assertTrue(
|
|
+ tests_in_iteration1 != tests_in_iteration2, tests_in_iteration1
|
|
+ )
|
|
+ self.assertTrue(
|
|
+ tests_in_iteration1 != tests_in_iteration3, tests_in_iteration1
|
|
+ )
|
|
+ self.assertTrue(
|
|
+ tests_in_iteration2 != tests_in_iteration3, tests_in_iteration2
|
|
+ )
|
|
|
|
def testShuffleShardedTestsPreservesPartition(self):
|
|
# If we run M tests on N shards, the same M tests should be run in
|
|
diff --git a/googletest/test/googletest-throw-on-failure-test.py b/googletest/test/googletest-throw-on-failure-test.py
|
|
index 772bbc5f..8fc4f54f 100755
|
|
--- a/googletest/test/googletest-throw-on-failure-test.py
|
|
+++ b/googletest/test/googletest-throw-on-failure-test.py
|
|
@@ -120,7 +120,7 @@ class ThrowOnFailureTest(gtest_test_utils.TestCase):
|
|
'exit code.' %
|
|
(THROW_ON_FAILURE, env_var_value_msg, ' '.join(command),
|
|
should_or_not))
|
|
- self.assert_(failed == should_fail, msg)
|
|
+ self.assertTrue(failed == should_fail, msg)
|
|
|
|
def testDefaultBehavior(self):
|
|
"""Tests the behavior of the default mode."""
|
|
diff --git a/googletest/test/gtest_testbridge_test.py b/googletest/test/gtest_testbridge_test.py
|
|
index 1c2a303a..0d58758b 100755
|
|
--- a/googletest/test/gtest_testbridge_test.py
|
|
+++ b/googletest/test/gtest_testbridge_test.py
|
|
@@ -52,7 +52,7 @@ class GTestTestFilterTest(gtest_test_utils.TestCase):
|
|
subprocess_env[TESTBRIDGE_NAME] = '*.TestThatSucceeds'
|
|
p = gtest_test_utils.Subprocess(COMMAND, env=subprocess_env)
|
|
|
|
- self.assertEquals(0, p.exit_code)
|
|
+ self.assertEqual(0, p.exit_code)
|
|
|
|
Assert('filter = *.TestThatSucceeds' in p.output)
|
|
Assert('[ OK ] TestFilterTest.TestThatSucceeds' in p.output)
|
|
diff --git a/googletest/test/gtest_xml_outfiles_test.py b/googletest/test/gtest_xml_outfiles_test.py
|
|
index c129e64b..73fb2b31 100755
|
|
--- a/googletest/test/gtest_xml_outfiles_test.py
|
|
+++ b/googletest/test/gtest_xml_outfiles_test.py
|
|
@@ -108,15 +108,17 @@ class GTestXMLOutFilesTest(gtest_xml_test_utils.GTestXMLTestCase):
|
|
command = [gtest_prog_path, "--gtest_output=xml:%s" % self.output_dir_]
|
|
p = gtest_test_utils.Subprocess(command,
|
|
working_dir=gtest_test_utils.GetTempDir())
|
|
- self.assert_(p.exited)
|
|
- self.assertEquals(0, p.exit_code)
|
|
+ self.assertTrue(p.exited)
|
|
+ self.assertEqual(0, p.exit_code)
|
|
|
|
output_file_name1 = test_name + ".xml"
|
|
output_file1 = os.path.join(self.output_dir_, output_file_name1)
|
|
output_file_name2 = 'lt-' + output_file_name1
|
|
output_file2 = os.path.join(self.output_dir_, output_file_name2)
|
|
- self.assert_(os.path.isfile(output_file1) or os.path.isfile(output_file2),
|
|
- output_file1)
|
|
+ self.assertTrue(
|
|
+ os.path.isfile(output_file1) or os.path.isfile(output_file2),
|
|
+ output_file1,
|
|
+ )
|
|
|
|
expected = minidom.parseString(expected_xml)
|
|
if os.path.isfile(output_file1):
|
|
diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py
|
|
index e1b7f1fc..29fbc41f 100755
|
|
--- a/googletest/test/gtest_xml_output_unittest.py
|
|
+++ b/googletest/test/gtest_xml_output_unittest.py
|
|
@@ -305,9 +305,9 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
|
|
p = gtest_test_utils.Subprocess(
|
|
[gtest_prog_path, '%s=xml' % GTEST_OUTPUT_FLAG],
|
|
working_dir=gtest_test_utils.GetTempDir())
|
|
- self.assert_(p.exited)
|
|
- self.assertEquals(0, p.exit_code)
|
|
- self.assert_(os.path.isfile(output_file))
|
|
+ self.assertTrue(p.exited)
|
|
+ self.assertEqual(0, p.exit_code)
|
|
+ self.assertTrue(os.path.isfile(output_file))
|
|
|
|
def testSuppressedXmlOutput(self):
|
|
"""
|
|
@@ -330,13 +330,15 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
|
|
p.terminated_by_signal,
|
|
'%s was killed by signal %d' % (GTEST_PROGRAM_NAME, p.signal))
|
|
else:
|
|
- self.assert_(p.exited)
|
|
- self.assertEquals(1, p.exit_code,
|
|
- "'%s' exited with code %s, which doesn't match "
|
|
- 'the expected exit code %s.'
|
|
- % (command, p.exit_code, 1))
|
|
+ self.assertTrue(p.exited)
|
|
+ self.assertEqual(
|
|
+ 1,
|
|
+ p.exit_code,
|
|
+ "'%s' exited with code %s, which doesn't match "
|
|
+ 'the expected exit code %s.' % (command, p.exit_code, 1),
|
|
+ )
|
|
|
|
- self.assert_(not os.path.isfile(xml_path))
|
|
+ self.assertFalse(os.path.isfile(xml_path))
|
|
|
|
def testFilteredTestXmlOutput(self):
|
|
"""Verifies XML output when a filter is applied.
|
|
@@ -380,14 +382,18 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
|
|
p = gtest_test_utils.Subprocess(command, env=environ_copy)
|
|
|
|
if p.terminated_by_signal:
|
|
- self.assert_(False,
|
|
- '%s was killed by signal %d' % (gtest_prog_name, p.signal))
|
|
+ self.assertTrue(
|
|
+ False, '%s was killed by signal %d' % (gtest_prog_name, p.signal)
|
|
+ )
|
|
else:
|
|
- self.assert_(p.exited)
|
|
- self.assertEquals(expected_exit_code, p.exit_code,
|
|
- "'%s' exited with code %s, which doesn't match "
|
|
- 'the expected exit code %s.'
|
|
- % (command, p.exit_code, expected_exit_code))
|
|
+ self.assertTrue(p.exited)
|
|
+ self.assertEqual(
|
|
+ expected_exit_code,
|
|
+ p.exit_code,
|
|
+ "'%s' exited with code %s, which doesn't match "
|
|
+ 'the expected exit code %s.'
|
|
+ % (command, p.exit_code, expected_exit_code),
|
|
+ )
|
|
actual = minidom.parse(xml_path)
|
|
return actual
|
|
|
|
diff --git a/googletest/test/gtest_xml_test_utils.py b/googletest/test/gtest_xml_test_utils.py
|
|
index c6fb9f44..ae41bbad 100755
|
|
--- a/googletest/test/gtest_xml_test_utils.py
|
|
+++ b/googletest/test/gtest_xml_test_utils.py
|
|
@@ -61,43 +61,59 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
|
|
"""
|
|
|
|
if expected_node.nodeType == Node.CDATA_SECTION_NODE:
|
|
- self.assertEquals(Node.CDATA_SECTION_NODE, actual_node.nodeType)
|
|
- self.assertEquals(expected_node.nodeValue, actual_node.nodeValue)
|
|
+ self.assertEqual(Node.CDATA_SECTION_NODE, actual_node.nodeType)
|
|
+ self.assertEqual(expected_node.nodeValue, actual_node.nodeValue)
|
|
return
|
|
|
|
- self.assertEquals(Node.ELEMENT_NODE, actual_node.nodeType)
|
|
- self.assertEquals(Node.ELEMENT_NODE, expected_node.nodeType)
|
|
- self.assertEquals(expected_node.tagName, actual_node.tagName)
|
|
+ self.assertEqual(Node.ELEMENT_NODE, actual_node.nodeType)
|
|
+ self.assertEqual(Node.ELEMENT_NODE, expected_node.nodeType)
|
|
+ self.assertEqual(expected_node.tagName, actual_node.tagName)
|
|
|
|
expected_attributes = expected_node.attributes
|
|
actual_attributes = actual_node.attributes
|
|
- self.assertEquals(
|
|
- expected_attributes.length, actual_attributes.length,
|
|
- 'attribute numbers differ in element %s:\nExpected: %r\nActual: %r' % (
|
|
- actual_node.tagName, expected_attributes.keys(),
|
|
- actual_attributes.keys()))
|
|
+ self.assertEqual(
|
|
+ expected_attributes.length,
|
|
+ actual_attributes.length,
|
|
+ 'attribute numbers differ in element %s:\nExpected: %r\nActual: %r'
|
|
+ % (
|
|
+ actual_node.tagName,
|
|
+ expected_attributes.keys(),
|
|
+ actual_attributes.keys(),
|
|
+ ),
|
|
+ )
|
|
for i in range(expected_attributes.length):
|
|
expected_attr = expected_attributes.item(i)
|
|
actual_attr = actual_attributes.get(expected_attr.name)
|
|
- self.assert_(
|
|
+ self.assertTrue(
|
|
actual_attr is not None,
|
|
- 'expected attribute %s not found in element %s' %
|
|
- (expected_attr.name, actual_node.tagName))
|
|
- self.assertEquals(
|
|
- expected_attr.value, actual_attr.value,
|
|
- ' values of attribute %s in element %s differ: %s vs %s' %
|
|
- (expected_attr.name, actual_node.tagName,
|
|
- expected_attr.value, actual_attr.value))
|
|
+ 'expected attribute %s not found in element %s'
|
|
+ % (expected_attr.name, actual_node.tagName),
|
|
+ )
|
|
+ self.assertEqual(
|
|
+ expected_attr.value,
|
|
+ actual_attr.value,
|
|
+ ' values of attribute %s in element %s differ: %s vs %s'
|
|
+ % (
|
|
+ expected_attr.name,
|
|
+ actual_node.tagName,
|
|
+ expected_attr.value,
|
|
+ actual_attr.value,
|
|
+ ),
|
|
+ )
|
|
|
|
expected_children = self._GetChildren(expected_node)
|
|
actual_children = self._GetChildren(actual_node)
|
|
- self.assertEquals(
|
|
- len(expected_children), len(actual_children),
|
|
- 'number of child elements differ in element ' + actual_node.tagName)
|
|
+ self.assertEqual(
|
|
+ len(expected_children),
|
|
+ len(actual_children),
|
|
+ 'number of child elements differ in element ' + actual_node.tagName,
|
|
+ )
|
|
for child_id, child in expected_children.items():
|
|
- self.assert_(child_id in actual_children,
|
|
- '<%s> is not in <%s> (in element %s)' %
|
|
- (child_id, actual_children, actual_node.tagName))
|
|
+ self.assertTrue(
|
|
+ child_id in actual_children,
|
|
+ '<%s> is not in <%s> (in element %s)'
|
|
+ % (child_id, actual_children, actual_node.tagName),
|
|
+ )
|
|
self.AssertEquivalentNodes(child, actual_children[child_id])
|
|
|
|
identifying_attribute = {
|
|
@@ -128,15 +144,19 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
|
|
for child in element.childNodes:
|
|
if child.nodeType == Node.ELEMENT_NODE:
|
|
if child.tagName == 'properties':
|
|
- self.assert_(child.parentNode is not None,
|
|
- 'Encountered <properties> element without a parent')
|
|
+ self.assertTrue(
|
|
+ child.parentNode is not None,
|
|
+ 'Encountered <properties> element without a parent',
|
|
+ )
|
|
child_id = child.parentNode.getAttribute('name') + '-properties'
|
|
else:
|
|
- self.assert_(child.tagName in self.identifying_attribute,
|
|
- 'Encountered unknown element <%s>' % child.tagName)
|
|
+ self.assertTrue(
|
|
+ child.tagName in self.identifying_attribute,
|
|
+ 'Encountered unknown element <%s>' % child.tagName,
|
|
+ )
|
|
child_id = child.getAttribute(
|
|
self.identifying_attribute[child.tagName])
|
|
- self.assert_(child_id not in children)
|
|
+ self.assertNotIn(child_id, children)
|
|
children[child_id] = child
|
|
elif child.nodeType in [Node.TEXT_NODE, Node.CDATA_SECTION_NODE]:
|
|
if 'detail' not in children:
|
|
--
|
|
2.39.0
|
|
|