parameters: (self, test_objs, internal_call=False)
return_statement: return test_suite
docstring: based on a filter name, only return those tests that have
              the test case names that match
docstring_summary: based on a filter name, only return those tests that have
              the test case names that match
docstring_tokens: based on a filter name only return those tests that have the test case names that match
function: def filter_tests(self, test_objs, internal_call=False):
          """ based on a filter name, only return those tests that have
              the test case names that match """
          import unittest
          if not internal_call:
              if not self.configuration.include_tests and not self.tests and not self.configuration.exclude_tests:
                  #No need to filter if we have nothing to filter!
                  return test_objs
  
              if self.verbosity > 1:
                  if self.configuration.include_tests:
                      sys.stdout.write('Tests to include: %s\n' % (self.configuration.include_tests,))
  
                  if self.tests:
                      sys.stdout.write('Tests to run: %s\n' % (self.tests,))
  
                  if self.configuration.exclude_tests:
                      sys.stdout.write('Tests to exclude: %s\n' % (self.configuration.exclude_tests,))
  
          test_suite = []
          for test_obj in test_objs:
  
              if isinstance(test_obj, unittest.TestSuite):
                  #Note: keep the suites as they are and just 'fix' the tests (so, don't use the iter_tests).
                  if test_obj._tests:
                      test_obj._tests = self.filter_tests(test_obj._tests, True)
                      if test_obj._tests:  #Only add the suite if we still have tests there.
                          test_suite.append(test_obj)
  
              elif isinstance(test_obj, unittest.TestCase):
                  try:
                      testMethodName = test_obj._TestCase__testMethodName
                  except AttributeError:
                      #changed in python 2.5
                      testMethodName = test_obj._testMethodName
  
                  add = True
                  if self.configuration.exclude_tests:
                      for pat in self.configuration.exclude_tests:
                          if fnmatch.fnmatchcase(testMethodName, pat):
                              if self.verbosity > 3:
                                  sys.stdout.write('Skipped test: %s (matched exclude_tests pattern: %s)\n' % (testMethodName, pat))
  
                              elif self.verbosity > 2:
                                  sys.stdout.write('Skipped test: %s\n' % (testMethodName,))
  
                              add = False
                              break
  
                  if add:
                      if self.__match_tests(self.tests, test_obj, testMethodName):
                          include = True
                          if self.configuration.include_tests:
                              include = False
                              for pat in self.configuration.include_tests:
                                  if fnmatch.fnmatchcase(testMethodName, pat):
                                      include = True
                                      break
                          if include:
                              test_suite.append(test_obj)
                          else:
                              if self.verbosity > 3:
                                  sys.stdout.write('Skipped test: %s (did not match any include_tests pattern %s)\n' % (
                                      testMethodName, self.configuration.include_tests,))
          return test_suite
function_tokens: def filter_tests ( self , test_objs , internal_call = False ) : import unittest if not internal_call : if not self . configuration . include_tests and not self . tests and not self . configuration . exclude_tests : #No need to filter if we have nothing to filter! return test_objs if self . verbosity > 1 : if self . configuration . include_tests : sys . stdout . write ( 'Tests to include: %s\n' % ( self . configuration . include_tests , ) ) if self . tests : sys . stdout . write ( 'Tests to run: %s\n' % ( self . tests , ) ) if self . configuration . exclude_tests : sys . stdout . write ( 'Tests to exclude: %s\n' % ( self . configuration . exclude_tests , ) ) test_suite = [ ] for test_obj in test_objs : if isinstance ( test_obj , unittest . TestSuite ) : #Note: keep the suites as they are and just 'fix' the tests (so, don't use the iter_tests). if test_obj . _tests : test_obj . _tests = self . filter_tests ( test_obj . _tests , True ) if test_obj . _tests : #Only add the suite if we still have tests there. test_suite . append ( test_obj ) elif isinstance ( test_obj , unittest . TestCase ) : try : testMethodName = test_obj . _TestCase__testMethodName except AttributeError : #changed in python 2.5 testMethodName = test_obj . _testMethodName add = True if self . configuration . exclude_tests : for pat in self . configuration . exclude_tests : if fnmatch . fnmatchcase ( testMethodName , pat ) : if self . verbosity > 3 : sys . stdout . write ( 'Skipped test: %s (matched exclude_tests pattern: %s)\n' % ( testMethodName , pat ) ) elif self . verbosity > 2 : sys . stdout . write ( 'Skipped test: %s\n' % ( testMethodName , ) ) add = False break if add : if self . __match_tests ( self . tests , test_obj , testMethodName ) : include = True if self . configuration . include_tests : include = False for pat in self . configuration . include_tests : if fnmatch . fnmatchcase ( testMethodName , pat ) : include = True break if include : test_suite . append ( test_obj ) else : if self . verbosity > 3 : sys . stdout . write ( 'Skipped test: %s (did not match any include_tests pattern %s)\n' % ( testMethodName , self . configuration . include_tests , ) ) return test_suite