From 48644f174e19a7014e81578042d5f7035ad2ff2d Mon Sep 17 00:00:00 2001 From: Darshit Shah Date: Fri, 6 Sep 2013 11:51:53 +0530 Subject: [PATCH] Print diff when file contents don't match --- testenv/ChangeLog | 5 +++++ testenv/WgetTest.py | 3 +++ 2 files changed, 8 insertions(+) diff --git a/testenv/ChangeLog b/testenv/ChangeLog index 12cc9e67..dc2f4a0b 100644 --- a/testenv/ChangeLog +++ b/testenv/ChangeLog @@ -1,3 +1,8 @@ +2013-09-06 Darshit Shah + + * 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 * HTTPServer.py (WgetHTTPRequestHandler.test_cookies): Comment out the diff --git a/testenv/WgetTest.py b/testenv/WgetTest.py index f71d1f37..7e2b2857 100644 --- a/testenv/WgetTest.py +++ b/testenv/WgetTest.py @@ -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")