Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2837)

Unified Diff: recipe_engine/recipe_test_api.py

Issue 1421843006: Add simple depends_on API. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/recipes-py@master
Patch Set: Remove old expectation, move tests to their own folder. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « recipe_engine/recipe_api.py ('k') | recipe_engine/run.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_engine/recipe_test_api.py
diff --git a/recipe_engine/recipe_test_api.py b/recipe_engine/recipe_test_api.py
index 4a54194489b410892b3fac0c14643ea055c0d385..dcb705650d2c2ff2dd5948a8a46a959df253bfb2 100644
--- a/recipe_engine/recipe_test_api.py
+++ b/recipe_engine/recipe_test_api.py
@@ -6,6 +6,7 @@ import collections
import contextlib
from .util import ModuleInjectionSite, static_call, static_wraps
+from .types import freeze
def combineify(name, dest, a, b):
"""
@@ -160,6 +161,7 @@ class TestData(BaseTestData):
self.properties = {} # key -> val
self.mod_data = collections.defaultdict(ModuleTestData)
self.step_data = collections.defaultdict(StepTestData)
+ self.depend_on_data = {}
self.expected_exception = None
def __add__(self, other):
@@ -171,6 +173,7 @@ class TestData(BaseTestData):
combineify('mod_data', ret, self, other)
combineify('step_data', ret, self, other)
+ combineify('depend_on_data', ret, self, other)
ret.expected_exception = self.expected_exception
if other.expected_exception:
ret.expected_exception = other.expected_exception
@@ -230,6 +233,12 @@ class TestData(BaseTestData):
if not should_raise:
self.expected_exception = None
+ def depend_on(self, recipe, properties, result):
+ tup = freeze((recipe, properties))
+ assert tup not in self.depend_on_data, (
+ 'Already gave test data for recipe %s with properties %r' % tup)
+ self.depend_on_data[tup] = freeze(result)
+
def __repr__(self):
return "TestData(%r)" % ({
'name': self.name,
@@ -237,6 +246,7 @@ class TestData(BaseTestData):
'mod_data': dict(self.mod_data.iteritems()),
'step_data': dict(self.step_data.iteritems()),
'expected_exception': self.expected_exception,
+ 'depend_on_data': self.depend_on_data,
},)
@@ -494,3 +504,8 @@ class RecipeTestApi(object):
ret = TestData(None)
ret.expect_exception(exc_type)
return ret
+
+ def depend_on(self, recipe, properties, result):
+ ret = TestData()
+ ret.depend_on(recipe, properties, result)
+ return ret
« no previous file with comments | « recipe_engine/recipe_api.py ('k') | recipe_engine/run.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698