aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDino Radakovic <dinor@google.com>2023-08-15 07:11:18 -0700
committerCopybara-Service <copybara-worker@google.com>2023-08-15 07:11:58 -0700
commit6513d0272d8bd2062cf4549fe2b0adb1fc862486 (patch)
treebbfb3fa95776f7ca755efbea85b645701f88912e
parentfc234d6d18b39dde39362e1d371886d4f9abf5a0 (diff)
downloadgoogletest-6513d0272d8bd2062cf4549fe2b0adb1fc862486.tar.gz
gtest_help_test: Inline test helper functions
`TestNonHelpFlag` is only a few asserts with no logic, which is easier to read in line, and helper `TestHelpFlag` is used in a single test case. PiperOrigin-RevId: 557122793 Change-Id: I7367424abfbb883c10c260fae066a2071e5dfa0e
-rwxr-xr-xgoogletest/test/gtest_help_test.py30
1 files changed, 7 insertions, 23 deletions
diff --git a/googletest/test/gtest_help_test.py b/googletest/test/gtest_help_test.py
index a76f220c..3f784960 100755
--- a/googletest/test/gtest_help_test.py
+++ b/googletest/test/gtest_help_test.py
@@ -116,17 +116,14 @@ def RunWithFlag(flag):
class GTestHelpTest(gtest_test_utils.TestCase):
"""Tests the --help flag and its equivalent forms."""
- def TestHelpFlag(self, flag):
+ def testPrintsHelpWithFullFlag(self):
"""Verifies correct behavior when help flag is specified.
The right message must be printed and the tests must
skipped when the given flag is specified.
-
- Args:
- flag: A flag to pass to the binary or None.
"""
- exit_code, output = RunWithFlag(flag)
+ exit_code, output = RunWithFlag('--help')
if HAS_ABSL_FLAGS:
# The Abseil flags library prints the ProgramUsageMessage() with
# --help and returns 1.
@@ -146,32 +143,17 @@ class GTestHelpTest(gtest_test_utils.TestCase):
else:
self.assertNotIn(DEATH_TEST_STYLE_FLAG, output)
- def TestNonHelpFlag(self, flag):
+ def testRunsTestsWithoutHelpFlag(self):
"""Verifies correct behavior when no help flag is specified.
Verifies that when no help flag is specified, the tests are run
and the help message is not printed.
-
- Args:
- flag: A flag to pass to the binary or None.
"""
- exit_code, output = RunWithFlag(flag)
+ exit_code, output = RunWithFlag(None)
self.assertNotEqual(exit_code, 0)
self.assertFalse(HELP_REGEX.search(output), output)
- def testPrintsHelpWithFullFlag(self):
- self.TestHelpFlag('--help')
-
- def testRunsTestsWithoutHelpFlag(self):
- """Verifies correct behavior when no help flag is specified.
-
- Verifies that when no help flag is specified, the tests are run
- and the help message is not printed.
- """
-
- self.TestNonHelpFlag(None)
-
def testRunsTestsWithGtestInternalFlag(self):
"""Verifies correct behavior when internal testing flag is specified.
@@ -179,7 +161,9 @@ class GTestHelpTest(gtest_test_utils.TestCase):
a flag starting with Google Test prefix and 'internal_' is supplied.
"""
- self.TestNonHelpFlag(INTERNAL_FLAG_FOR_TESTING)
+ exit_code, output = RunWithFlag(INTERNAL_FLAG_FOR_TESTING)
+ self.assertNotEqual(exit_code, 0)
+ self.assertFalse(HELP_REGEX.search(output), output)
if __name__ == '__main__':