media/webrtc/trunk/build/android/pylib/tests_annotations.py

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
     2 # Use of this source code is governed by a BSD-style license that can be
     3 # found in the LICENSE file.
     5 """Annotations for python-driven tests."""
     7 import os
    10 class AnnotatedFunctions(object):
    11   """A container for annotated methods."""
    12   _ANNOTATED = {}
    14   @staticmethod
    15   def _AddFunction(annotation, function):
    16     """Adds an annotated to function to our container.
    18     Args:
    19       annotation: the annotation string.
    20       function: the function.
    21     Returns:
    22       The function passed in.
    23     """
    24     module_name = os.path.splitext(os.path.basename(
    25         function.__globals__['__file__']))[0]
    26     qualified_function_name = '.'.join([module_name, function.func_name])
    27     function_list = AnnotatedFunctions._ANNOTATED.get(annotation, [])
    28     function_list.append(qualified_function_name)
    29     AnnotatedFunctions._ANNOTATED[annotation] = function_list
    30     return function
    32   @staticmethod
    33   def IsAnnotated(annotation, qualified_function_name):
    34     """True if function name (module.function) contains the annotation.
    36     Args:
    37       annotation: the annotation string.
    38       qualified_function_name: the qualified function name.
    39     Returns:
    40       True if module.function contains the annotation.
    41     """
    42     return qualified_function_name in AnnotatedFunctions._ANNOTATED.get(
    43         annotation, [])
    45   @staticmethod
    46   def GetTestAnnotations(qualified_function_name):
    47     """Returns a list containing all annotations for the given function.
    49     Args:
    50       qualified_function_name: the qualified function name.
    51     Returns:
    52       List of all annotations for this function.
    53     """
    54     return [annotation
    55             for annotation, tests in AnnotatedFunctions._ANNOTATED.iteritems()
    56             if qualified_function_name in tests]
    59 # The following functions are annotations used for the python driven tests.
    60 def Smoke(function):
    61   return AnnotatedFunctions._AddFunction('Smoke', function)
    64 def SmallTest(function):
    65   return AnnotatedFunctions._AddFunction('SmallTest', function)
    68 def MediumTest(function):
    69   return AnnotatedFunctions._AddFunction('MediumTest', function)
    72 def LargeTest(function):
    73   return AnnotatedFunctions._AddFunction('LargeTest', function)
    76 def FlakyTest(function):
    77   return AnnotatedFunctions._AddFunction('FlakyTest', function)
    80 def DisabledTest(function):
    81   return AnnotatedFunctions._AddFunction('DisabledTest', function)
    84 def Feature(feature_list):
    85   def _AddFeatures(function):
    86     for feature in feature_list:
    87       AnnotatedFunctions._AddFunction('Feature' + feature, function)
    88     return AnnotatedFunctions._AddFunction('Feature', function)
    89   return _AddFeatures

mercurial