diff tests/conftest.py @ 398:af17c143b9ab

tests: Fail bake tests with a proper error message when bake fails.
author Ludovic Chabant <ludovic@chabant.com>
date Mon, 18 May 2015 19:28:47 -0700
parents 879b6b5647a8
children a0724af26c12
line wrap: on
line diff
--- a/tests/conftest.py	Mon May 18 15:48:45 2015 -0700
+++ b/tests/conftest.py	Mon May 18 19:28:47 2015 -0700
@@ -146,7 +146,13 @@
             out_dir = fs.path('kitchen/_counter')
             app = fs.getApp()
             baker = Baker(app, out_dir)
-            baker.bake()
+            record = baker.bake()
+
+        if not record.success:
+            errors = []
+            for e in record.entries:
+                errors += e.getAllErrors()
+            raise BakeError(errors)
 
         if expected_output_files:
             actual = fs.getStructure('kitchen/_counter')
@@ -182,9 +188,17 @@
                 ['Unexpected bake output. Left is expected output, '
                     'right is actual output'] +
                 excinfo.value.args[0]))
+        elif isinstance(excinfo.value, BakeError):
+            return ('\n'.join(
+                ['Errors occured during bake:'] +
+                excinfo.value.args[0]))
         return super(BakeTestItem, self).repr_failure(excinfo)
 
 
+class BakeError(Exception):
+    pass
+
+
 class ExpectedBakeOutputError(Exception):
     pass