def _assert_reports_equal(self, report, expected_report): """ Asserts that two console reports are equal, with some extra debugging logging. Strips the strings to avoid failures due to starting/ending newline issues. """ assert_long_str_equal(report, expected_report, strip=True)
def assert_tool_stdout(expected_filename): """ Assert that the output of the tool is equal to the content of the fixture file at `expected_filename`. """ # Retrieve captured stdout from our mock system captured_stdout = world.mock_sys_runner.stdout.getvalue() # Open the file containing the expected report # and check that it matches the stdout captured by the tool with open(expected_filename) as expected_file: assert_long_str_equal(expected_file.read(), captured_stdout)
def compare_files_at_paths(actual_filename, expected_filename): """ Assert that the contents of the fixture files at `actual_filename` and `expected_filename` are equal. """ # Check that both files exist (to print a better error message) world.assert_file_exists(actual_filename) world.assert_file_exists(expected_filename) # Open both files and compare the contents with open(actual_filename) as actual_file: with open(expected_filename) as expected_file: assert_long_str_equal( expected_file.read().strip(), actual_file.read().strip() )
def assert_report(self, expected_report): """ Assert that the console report matches `expected_report`. """ assert_long_str_equal(self.build_report(), expected_report, strip=True)