def test_str(self): self.assertEqual( str(CommandLineTextSource("--foo", "value")), "command line argument --foo='value'") self.assertEqual( str(CommandLineTextSource(None, "value")), "command line argument 'value'")
def select_qualifier_list(self): # Add whitelists if 'whitelist' in self.ns and self.ns.whitelist: for whitelist_file in self.ns.whitelist: qualifier = self.get_whitelist_from_file( whitelist_file.name, whitelist_file) if qualifier is not None: self._qualifier_list.append(qualifier) # Add all the --include jobs for pattern in self.ns.include_pattern_list: origin = Origin(CommandLineTextSource('-i', pattern), None, None) try: qualifier = RegExpJobQualifier('^{}$'.format(pattern), origin, inclusive=True) except Exception as exc: logger.warning(_("Incorrect pattern %r: %s"), pattern, exc) else: self._qualifier_list.append(qualifier) # Add all the --exclude jobs for pattern in self.ns.exclude_pattern_list: origin = Origin(CommandLineTextSource('-x', pattern), None, None) try: qualifier = RegExpJobQualifier('^{}$'.format(pattern), origin, inclusive=False) except Exception as exc: logger.warning(_("Incorrect pattern %r: %s"), pattern, exc) else: self._qualifier_list.append(qualifier) if self.config.whitelist is not Unset: self._qualifier_list.append( self.get_whitelist_from_file(self.config.whitelist))
def _get_matching_job_list(self, ns, job_list): logger.debug("_get_matching_job_list(%r, %r)", ns, job_list) qualifier_list = [] # Add the test plan if ns.test_plan is not None: # Uh, dodgy, recreate a list of providers from the list of jobs we # know about here. This code needs to be re-factored to use the # upcoming provider store class. for provider in {job.provider for job in job_list}: for unit in provider.id_map[ns.test_plan]: if unit.Meta.name == 'test plan': qualifier_list.append(unit.get_qualifier()) break else: logger.debug(_("There is no test plan: %s"), ns.test_plan) # Add whitelists for whitelist_file in ns.whitelist: qualifier = self.get_whitelist_from_file(whitelist_file.name, whitelist_file) if qualifier is not None: qualifier_list.append(qualifier) # Add all the --include jobs for pattern in ns.include_pattern_list: origin = Origin(CommandLineTextSource('-i', pattern), None, None) try: qualifier = RegExpJobQualifier('^{}$'.format(pattern), origin, inclusive=True) except Exception as exc: logger.warning(_("Incorrect pattern %r: %s"), pattern, exc) else: qualifier_list.append(qualifier) # Add all the --exclude jobs for pattern in ns.exclude_pattern_list: origin = Origin(CommandLineTextSource('-x', pattern), None, None) try: qualifier = RegExpJobQualifier('^{}$'.format(pattern), origin, inclusive=False) except Exception as exc: logger.warning(_("Incorrect pattern %r: %s"), pattern, exc) else: qualifier_list.append(qualifier) logger.debug("select_jobs(%r, %r)", job_list, qualifier_list) return select_jobs(job_list, qualifier_list)
def test_gt(self): src1 = CommandLineTextSource("--arg2", "value") src2 = CommandLineTextSource("--arg1", "value") self.assertGreater(src1, src2)
def test_eq(self): src1 = CommandLineTextSource("--foo", "value") src2 = CommandLineTextSource("--foo", "value") self.assertEqual(src1, src2)
def test_relative_to(self): src = CommandLineTextSource("--foo", "value") self.assertIs(src.relative_to('path'), src)
def test_repr(self): self.assertEqual( repr(CommandLineTextSource("--foo", "value")), "<CommandLineTextSource arg_name:'--foo' arg_value:'value'>")