Chromium Code Reviews| Index: recipe_engine/recipe_test_api.py |
| diff --git a/recipe_engine/recipe_test_api.py b/recipe_engine/recipe_test_api.py |
| index bb1da1cf0b66c6c54c7829a388d741a477ee3f9d..3b544bfc41fd99c90ce07073316bec38ecc1f037 100644 |
| --- a/recipe_engine/recipe_test_api.py |
| +++ b/recipe_engine/recipe_test_api.py |
| @@ -5,6 +5,7 @@ |
| import collections |
| from .util import ModuleInjectionSite, static_call, static_wraps |
| +from .types import freeze |
| def combineify(name, dest, a, b): |
| """ |
| @@ -159,6 +160,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): |
| @@ -173,6 +175,8 @@ class TestData(BaseTestData): |
| ret.expected_exception = self.expected_exception |
| if other.expected_exception: |
| ret.expected_exception = other.expected_exception |
| + ret.depend_on_data.update(self.depend_on_data) |
|
Paweł Hajdan Jr.
2015/11/13 12:30:00
Would it make sense to use combineify here for con
martiniss
2015/11/13 23:19:02
That works alright. Fixed.
|
| + ret.depend_on_data.update(other.depend_on_data) |
| return ret |
| @@ -198,6 +202,11 @@ class TestData(BaseTestData): |
| name = exception.__class__.__name__ |
| return not (self.enabled and name == self.expected_exception) |
| + def depend_on(self, recipe, properties, result): |
| + assert recipe not in self.depend_on_data, ( |
|
Paweł Hajdan Jr.
2015/11/13 12:30:00
If I understand this correctly, this uses recipe a
martiniss
2015/11/13 23:19:02
Changed to recipe, properties.
|
| + "Already gave test data for %s" % recipe) |
|
Paweł Hajdan Jr.
2015/11/13 12:30:00
nit: Prefer single quotes ' .
martiniss
2015/11/13 23:19:02
Fixed.
|
| + self.depend_on_data[recipe] = freeze((properties, result)) |
| + |
| def __repr__(self): |
| return "TestData(%r)" % ({ |
| 'name': self.name, |
| @@ -205,6 +214,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 |
| },) |
| @@ -462,3 +472,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 |