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

Unified Diff: recipe_engine/test.py

Issue 2850543002: Fix recipes.py test train when on-disk expectation files are invalid (Closed)
Patch Set: Created 3 years, 8 months 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 | « no previous file | unittests/test_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_engine/test.py
diff --git a/recipe_engine/test.py b/recipe_engine/test.py
index 2924b206e684ff3b3738f9885ab45175148460fa..d3704db5b78d6b801f08d5b9b3c02c7f34239c05 100644
--- a/recipe_engine/test.py
+++ b/recipe_engine/test.py
@@ -207,9 +207,16 @@ def run_test(test_description, debug=False, train=False):
"""Runs a test. Returns TestResults object."""
expected = None
if os.path.exists(test_description.expectation_path):
- with open(test_description.expectation_path) as f:
- # TODO(phajdan.jr): why do we need to re-encode golden data files?
- expected = re_encode(json.load(f))
+ try:
+ with open(test_description.expectation_path) as f:
+ # TODO(phajdan.jr): why do we need to re-encode golden data files?
+ expected = re_encode(json.load(f))
+ except Exception:
+ if train:
+ # Ignore errors when training; we're going to overwrite the file anyway.
+ expected = None
+ else:
+ raise
break_funcs = [
_UNIVERSE_VIEW.load_recipe(test_description.recipe_name).run_steps,
« no previous file with comments | « no previous file | unittests/test_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698