tesseract v5.3.3.20231005
googletest-list-tests-unittest.GTestListTestsUnitTest Class Reference
Inheritance diagram for googletest-list-tests-unittest.GTestListTestsUnitTest:

Public Member Functions

def RunAndVerify (self, flag_value, expected_output_re, other_flag)
 
def testDefaultBehavior (self)
 
def testFlag (self)
 
def testOverrideNonFilterFlags (self)
 
def testWithFilterFlags (self)
 

Detailed Description

Tests using the --gtest_list_tests flag to list all tests.

Definition at line 124 of file googletest-list-tests-unittest.py.

Member Function Documentation

◆ RunAndVerify()

def googletest-list-tests-unittest.GTestListTestsUnitTest.RunAndVerify (   self,
  flag_value,
  expected_output_re,
  other_flag 
)
Runs googletest-list-tests-unittest_ and verifies that it prints
the correct tests.

Args:
  flag_value:         value of the --gtest_list_tests flag;
                      None if the flag should not be present.
  expected_output_re: regular expression that matches the expected
                      output after running command;
  other_flag:         a different flag to be passed to command
                      along with gtest_list_tests;
                      None if the flag should not be present.

Definition at line 127 of file googletest-list-tests-unittest.py.

127 def RunAndVerify(self, flag_value, expected_output_re, other_flag):
128 """Runs googletest-list-tests-unittest_ and verifies that it prints
129 the correct tests.
130
131 Args:
132 flag_value: value of the --gtest_list_tests flag;
133 None if the flag should not be present.
134 expected_output_re: regular expression that matches the expected
135 output after running command;
136 other_flag: a different flag to be passed to command
137 along with gtest_list_tests;
138 None if the flag should not be present.
139 """
140
141 if flag_value is None:
142 flag = ''
143 flag_expression = 'not set'
144 elif flag_value == '0':
145 flag = '--%s=0' % LIST_TESTS_FLAG
146 flag_expression = '0'
147 else:
148 flag = '--%s' % LIST_TESTS_FLAG
149 flag_expression = '1'
150
151 args = [flag]
152
153 if other_flag is not None:
154 args += [other_flag]
155
156 output = Run(args)
157
158 if expected_output_re:
159 self.assert_(
160 expected_output_re.match(output),
161 ('when %s is %s, the output of "%s" is "%s",\n'
162 'which does not match regex "%s"' %
163 (LIST_TESTS_FLAG, flag_expression, ' '.join(args), output,
164 expected_output_re.pattern)))
165 else:
166 self.assert_(
167 not EXPECTED_OUTPUT_NO_FILTER_RE.match(output),
168 ('when %s is %s, the output of "%s" is "%s"'%
169 (LIST_TESTS_FLAG, flag_expression, ' '.join(args), output)))
170

◆ testDefaultBehavior()

def googletest-list-tests-unittest.GTestListTestsUnitTest.testDefaultBehavior (   self)
Tests the behavior of the default mode.

Definition at line 171 of file googletest-list-tests-unittest.py.

171 def testDefaultBehavior(self):
172 """Tests the behavior of the default mode."""
173
174 self.RunAndVerify(flag_value=None,
175 expected_output_re=None,
176 other_flag=None)
177

◆ testFlag()

def googletest-list-tests-unittest.GTestListTestsUnitTest.testFlag (   self)
Tests using the --gtest_list_tests flag.

Definition at line 178 of file googletest-list-tests-unittest.py.

178 def testFlag(self):
179 """Tests using the --gtest_list_tests flag."""
180
181 self.RunAndVerify(flag_value='0',
182 expected_output_re=None,
183 other_flag=None)
184 self.RunAndVerify(flag_value='1',
185 expected_output_re=EXPECTED_OUTPUT_NO_FILTER_RE,
186 other_flag=None)
187

◆ testOverrideNonFilterFlags()

def googletest-list-tests-unittest.GTestListTestsUnitTest.testOverrideNonFilterFlags (   self)
Tests that --gtest_list_tests overrides the non-filter flags.

Definition at line 188 of file googletest-list-tests-unittest.py.

188 def testOverrideNonFilterFlags(self):
189 """Tests that --gtest_list_tests overrides the non-filter flags."""
190
191 self.RunAndVerify(flag_value='1',
192 expected_output_re=EXPECTED_OUTPUT_NO_FILTER_RE,
193 other_flag='--gtest_break_on_failure')
194

◆ testWithFilterFlags()

def googletest-list-tests-unittest.GTestListTestsUnitTest.testWithFilterFlags (   self)
Tests that --gtest_list_tests takes into account the
--gtest_filter flag.

Definition at line 195 of file googletest-list-tests-unittest.py.

195 def testWithFilterFlags(self):
196 """Tests that --gtest_list_tests takes into account the
197 --gtest_filter flag."""
198
199 self.RunAndVerify(flag_value='1',
200 expected_output_re=EXPECTED_OUTPUT_FILTER_FOO_RE,
201 other_flag='--gtest_filter=Foo*')
202
203

The documentation for this class was generated from the following file: