Print diff when file contents don't match

This commit is contained in:
Darshit Shah 2013-09-06 11:51:53 +05:30
parent b6f9efe7b5
commit 48644f174e
2 changed files with 8 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2013-09-06 Darshit Shah <darnir@gmail.com>
* WgetTest.py (CommonMethods.__check_downloaded_files): Print a
unified diff in case there is a mismatch in the file contents
2013-09-06 Darshit Shah <darnir@gmail.com>
* HTTPServer.py (WgetHTTPRequestHandler.test_cookies): Comment out the

View File

@ -8,6 +8,7 @@ import http.client
import re
from subprocess import call
from ColourTerm import printer
from difflib import unified_diff
""" A Custom Exception raised by the Test Environment. """
@ -92,6 +93,8 @@ class CommonMethods:
if files.name in local_filesys:
local_file = local_filesys.pop (files.name)
if files.content != local_file ['content']:
for line in unified_diff (local_file['content'], files.content, fromfile="Actual", tofile="Expected"):
sys.stderr.write (line)
raise TestFailed ("Contents of " + files.name + " do not match")
else:
raise TestFailed ("Expected file " + files.name + " not found")