def ClassifyTestWithBrowser(test_set, test): name = test.id() if (not args.positional_args or _MatchesSelectedTest(name, args.positional_args, args.exact_test_filter)): assert hasattr(test, '_testMethodName') method = getattr(test, test._testMethodName) # pylint: disable=W0212 should_skip, reason = decorators.ShouldSkip(method, possible_browser) if should_skip and not args.run_disabled_tests: test_set.tests_to_skip.append(typ.TestInput(name, msg=reason)) elif decorators.ShouldBeIsolated(method, possible_browser): test_set.isolated_tests.append(typ.TestInput(name)) else: test_set.parallel_tests.append(typ.TestInput(name))
def ClassifyTestWithBrowser(test_set, test): if typ_runner.matches_filter(test): if typ_runner.should_skip(test): test_set.add_test_to_skip(test, 'skipped because matched --skip') return assert hasattr(test, '_testMethodName') method = getattr(test, test._testMethodName) # pylint: disable=protected-access should_skip, reason = decorators.ShouldSkip( method, possible_browser) if should_skip and not typ_runner.args.all: test_set.add_test_to_skip(test, reason) elif decorators.ShouldBeIsolated(method, possible_browser): test_set.add_test_to_run_isolated(test) else: test_set.add_test_to_run_in_parallel(test)
def ClassifyTestWithBrowser(test_set, test): name = test.id() if _SkipMatch(name, args.skip): test_set.tests_to_skip.append( typ.TestInput(name, 'skipped because matched --skip')) return if (not selected_tests or _MatchesSelectedTest(name, selected_tests, selected_tests_are_exact)): assert hasattr(test, '_testMethodName') method = getattr( test, test._testMethodName) # pylint: disable=protected-access should_skip, reason = decorators.ShouldSkip(method, possible_browser) if should_skip and not args.run_disabled_tests: test_set.tests_to_skip.append(typ.TestInput(name, msg=reason)) elif decorators.ShouldBeIsolated(method, possible_browser): test_set.isolated_tests.append(typ.TestInput(name)) else: test_set.parallel_tests.append(typ.TestInput(name))
def _GetPossibleBrowser(self): """Return a possible_browser with the given options.""" possible_browser = browser_finder.FindBrowser(self._finder_options) if not possible_browser: raise browser_finder_exceptions.BrowserFinderException( 'Cannot find browser of type %s. \n\nAvailable browsers:\n%s\n' % ( self._finder_options.browser_options.browser_type, '\n'.join(browser_finder.GetAllAvailableBrowserTypes( self._finder_options)))) self._finder_options.browser_options.browser_type = ( possible_browser.browser_type) if self._page_test: # Check for Enabled/Disabled decorators on page_test. skip, msg = decorators.ShouldSkip(self._page_test, possible_browser) if skip and not self._finder_options.run_disabled_tests: logging.warning(msg) logging.warning('You are trying to run a disabled test.') return possible_browser
def testDisabledStrings(self): test = FakeTest() possible_browser = FakePossibleBrowser() # When no disabled_strings is given, nothing should be disabled. self.assertFalse(decorators.ShouldSkip(test, possible_browser)[0]) test.SetDisabledStrings(['os_name']) self.assertTrue(decorators.ShouldSkip(test, possible_browser)[0]) test.SetDisabledStrings(['another_os_name']) self.assertFalse(decorators.ShouldSkip(test, possible_browser)[0]) test.SetDisabledStrings(['os_version_name']) self.assertTrue(decorators.ShouldSkip(test, possible_browser)[0]) test.SetDisabledStrings(['os_name', 'another_os_name']) self.assertTrue(decorators.ShouldSkip(test, possible_browser)[0]) test.SetDisabledStrings(['another_os_name', 'os_name']) self.assertTrue(decorators.ShouldSkip(test, possible_browser)[0]) test.SetDisabledStrings(['another_os_name', 'another_os_version_name']) self.assertFalse(decorators.ShouldSkip(test, possible_browser)[0])
def CanRun(cls, possible_browser): if (decorators.ShouldSkip(cls, possible_browser)[0] or cls.ShouldDisable(possible_browser)): return False return True
def testEnabledStrings(self): test = FakeTest() # When no enabled_strings is given, everything should be enabled. self.assertFalse(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetEnabledStrings(['os_name']) self.assertFalse(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetEnabledStrings(['another_os_name']) self.assertTrue(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetEnabledStrings(['os_version_name']) self.assertFalse(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetEnabledStrings(['os_name', 'another_os_name']) self.assertFalse(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetEnabledStrings(['another_os_name', 'os_name']) self.assertFalse(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetEnabledStrings(['another_os_name', 'another_os_version_name']) self.assertTrue(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetEnabledStrings(['os_name-reference']) self.assertTrue(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetEnabledStrings(['another_os_name-reference']) self.assertTrue(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetEnabledStrings(['os_version_name-reference']) self.assertTrue(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetEnabledStrings( ['os_name-reference', 'another_os_name-reference']) self.assertTrue(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetEnabledStrings( ['another_os_name-reference', 'os_name-reference']) self.assertTrue(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetEnabledStrings( ['another_os_name-reference', 'another_os_version_name-reference']) self.assertTrue(decorators.ShouldSkip(test, self.possible_browser)[0])
def testDisabledStrings(self): test = FakeTest() # When no disabled_strings is given, nothing should be disabled. self.assertFalse(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetDisabledStrings(['os_name']) self.assertTrue(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetDisabledStrings(['another_os_name']) self.assertFalse(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetDisabledStrings(['os_version_name']) self.assertTrue(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetDisabledStrings(['os_name', 'another_os_name']) self.assertTrue(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetDisabledStrings(['another_os_name', 'os_name']) self.assertTrue(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetDisabledStrings(['another_os_name', 'another_os_version_name']) self.assertFalse(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetDisabledStrings(['reference']) self.assertFalse(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetDisabledStrings(['os_name-reference']) self.assertFalse(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetDisabledStrings(['another_os_name-reference']) self.assertFalse(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetDisabledStrings(['os_version_name-reference']) self.assertFalse(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetDisabledStrings( ['os_name-reference', 'another_os_name-reference']) self.assertFalse(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetDisabledStrings( ['another_os_name-reference', 'os_name-reference']) self.assertFalse(decorators.ShouldSkip(test, self.possible_browser)[0]) test.SetDisabledStrings( ['another_os_name-reference', 'another_os_version_name-reference']) self.assertFalse(decorators.ShouldSkip(test, self.possible_browser)[0]) self.possible_browser.GetTypExpectationsTags.return_value = [ 'typ_value' ] test.SetDisabledStrings(['typ_value']) self.assertTrue(decorators.ShouldSkip(test, self.possible_browser)[0])