def _choose_tagged_tests(tests, tags):
 selected = []
 tags = set(tags)
 for test in _flatten_suite(tests):
  assert isinstance(test, unittest.TestCase)
  func = getattr(test, test._testMethodName)
  try:
   func = func.im_func
  except AttributeError:
   pass
  try:
   if (func.tags & tags):
    selected.append(test)
  except AttributeError:
   pass
 return unittest.TestSuite(selected)

def _choose_tagged_tests ( tests , tags ) : selected = [ ] tags = set ( tags ) for test in _flatten_suite ( tests ) : assert isinstance ( test , unittest . TestCase ) func = getattr ( test , test . _testMethodName ) try : func = func . im_func except AttributeError : pass try : if ( func . tags & tags ) : selected . append ( test ) except AttributeError : pass return unittest . TestSuite ( selected )
select tests that are tagged with at least one of the given tags .