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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial