From 6513d0272d8bd2062cf4549fe2b0adb1fc862486 Mon Sep 17 00:00:00 2001 From: Dino Radakovic Date: Tue, 15 Aug 2023 07:11:18 -0700 Subject: [PATCH] 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 --- googletest/test/gtest_help_test.py | 32 ++++++++---------------------- 1 file changed, 8 insertions(+), 24 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,23 +143,6 @@ class GTestHelpTest(gtest_test_utils.TestCase): else: self.assertNotIn(DEATH_TEST_STYLE_FLAG, output) - def TestNonHelpFlag(self, flag): - """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) - 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. @@ -170,7 +150,9 @@ class GTestHelpTest(gtest_test_utils.TestCase): and the help message is not printed. """ - self.TestNonHelpFlag(None) + exit_code, output = RunWithFlag(None) + self.assertNotEqual(exit_code, 0) + self.assertFalse(HELP_REGEX.search(output), output) 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__':