Mercurial > piecrust2
diff tests/conftest.py @ 559:b95977d97652
tests: Print more information when a bake test fails to find an output file.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 14 Aug 2015 22:43:39 -0700 |
parents | cc6f3dbe3048 |
children | a65f04ddbea2 |
line wrap: on
line diff
--- a/tests/conftest.py Fri Aug 14 21:26:51 2015 -0700 +++ b/tests/conftest.py Fri Aug 14 22:43:39 2015 -0700 @@ -99,8 +99,11 @@ actual = fs.getFileEntry('kitchen/_counter/' + key.lstrip('/')) except Exception as e: + lines = print_fs_tree(fs.path('kitchen/_counter')) raise error_type([ - "Can't access output file %s: %s" % (key, e)]) + "Can't access output file %s: %s" % (key, e), + "Got output directory:"] + + lines) expected = expected_partial_files[key] # HACK because for some reason PyYAML adds a new line for @@ -113,6 +116,21 @@ raise error_type(cmpres) +def print_fs_tree(rootpath): + import os + import os.path + lines = [] + offset = len(rootpath) + for pathname, dirnames, filenames in os.walk(rootpath): + level = pathname[offset:].count(os.sep) + indent = ' ' * 4 * (level) + lines.append(indent + os.path.basename(pathname) + '/') + indent2 = ' ' * 4 * (level + 1) + for f in filenames: + lines.append(indent2 + f) + return lines + + class ChefTestItem(YamlTestItemBase): __initialized_logging__ = False