# HG changeset patch # User Ludovic Chabant # Date 1432002527 25200 # Node ID af17c143b9ab3ec8bce3d5f5664846cf937a3e4e # Parent 879b6b5647a88fb19b6b5a6674c2ace113213c81 tests: Fail bake tests with a proper error message when bake fails. diff -r 879b6b5647a8 -r af17c143b9ab tests/conftest.py --- 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