def test_update_file(): """ Expected output table_updated.html and table_updated_solution.html are the same docs_updated.html and docs_updated_solution.html are the same """ # A couple of test files update_file("table.html", "table_updated.html") update_file("docs.html", "docs_updated.html") # file_diff.compare_files("table_updated.html", "table_updated_solution.html") file_diff.compare_files("docs_updated.html", "docs_updated_solution.html")
updated_text = "" # split text in <pre> blocks and update using update_pre_block() content_split_PREFIX = whole_file.split(PREFIX) updated_text = updated_text + content_split_PREFIX[ 0] #The content before PREFIX is unchangedly inserted into output file for content in content_split_PREFIX[1:]: updated_text += PREFIX [pre_block, post_block] = content.split( POSTFIX, 1 ) #Specify the maxsplit will only return maxsplit+1 elements. In this case, only first POSTFIX will be considered updated_text += update_pre_block(pre_block) + POSTFIX + post_block # Write the answer in the specified output file new_file = open(output_file_name, "wt") new_file.write(updated_text) new_file.close() # A couple of test files update_file("table.html", "table_updated.html") update_file("docs.html", "docs_updated.html") # Import some code to check whether the computed files are correct import examples3_file_diff as file_diff file_diff.compare_files("table_updated.html", "table_updated_solution.html") file_diff.compare_files("docs_updated.html", "docs_updated_solution.html") # Expected output ##table_updated.html and table_updated_solution.html are the same ##docs_updated.html and docs_updated_solution.html are the same