def _make_format_msg(actual_dir, expected_dir, context, test_name, test_description): """ Return the format_msg function to pass to assertDirectoriesEqual(). """ # TODO: review the relationship between "directory name" and "test name". format_string = ( dedent( """\ Rendered directories differ: Expected | Actual : %s %s %%s Context: %s Test template info: Directory name: %s Description: %s""" ) % (expected_dir, actual_dir, indent(pformat(context), " "), repr(test_name), test_description) ) def format_msg(details): msg = format_string % indent(details, " ") return msg return format_msg
def _assert_empty(self, dcmp, attr_name, should_ignore, format_msg): """ Arguments: dcmp: a filecmp.dircmp ("directory comparison") instance. attr: a dircmp attribute name. """ attr_val = self._get_dcmp_attr(dcmp, attr_name, should_ignore=should_ignore) if not attr_val: return # Otherwise, raise the test failure. lines = ["dircmp.%s = %s" % (attr, self._get_dcmp_attr(dcmp, attr, should_ignore=should_ignore)) for attr in DIRCMP_ATTRS] attr_details = "\n".join(lines) details = ("Attribute %s non-empty for directory compare:\n%s" % (repr(attr_name), indent(attr_details, " "))) self.fail(format_msg(details))
def subdir_format_msg(subdir_details): details = format_string % indent(subdir_details, " ") return format_msg(details)
def assert_files_format_msg(assert_file_details): details = format_string % indent(assert_file_details, " ") return format_msg(details)
def format_msg(details): msg = format_string % indent(details, " ") return msg