[diffoscope] 01/01: Do the tool_required dance properly so the tests don't fail

Ximin Luo infinity0 at debian.org
Tue Nov 29 21:32:09 UTC 2016


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository diffoscope.

commit 6e7d6b3f0b9390f25c15fcd7a04973d0e25a2fcb
Author: Ximin Luo <infinity0 at debian.org>
Date:   Tue Nov 29 22:31:22 2016 +0100

    Do the tool_required dance properly so the tests don't fail
---
 diffoscope/difference.py      | 11 +++++++++++
 diffoscope/presenters/text.py |  8 ++------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/diffoscope/difference.py b/diffoscope/difference.py
index c55819e..edbc5f9 100644
--- a/diffoscope/difference.py
+++ b/diffoscope/difference.py
@@ -449,3 +449,14 @@ def reverse_unified_diff(diff):
         else:
             res.append(line)
     return ''.join(res)
+
+
+ at tool_required('colordiff')
+def color_unified_diff(diff):
+    with subprocess.Popen(["colordiff"],
+                          stdin=subprocess.PIPE,
+                          stdout=subprocess.PIPE,
+                          universal_newlines=True) as proc:
+        diff_output, _ = proc.communicate(diff)
+        return diff_output
+
diff --git a/diffoscope/presenters/text.py b/diffoscope/presenters/text.py
index 0929f40..ae7e131 100644
--- a/diffoscope/presenters/text.py
+++ b/diffoscope/presenters/text.py
@@ -22,20 +22,16 @@ import subprocess
 import sys
 
 from diffoscope import logger, tool_required
+from diffoscope.difference import color_unified_diff
 
 
- at tool_required('colordiff')
 def print_difference(difference, print_func, color=False):
     if difference.comments:
         for comment in difference.comments:
             print_func(u"│┄ %s" % comment)
     if difference.unified_diff:
         if color:
-            with subprocess.Popen(["colordiff"],
-                                  stdin=subprocess.PIPE,
-                                  stdout=subprocess.PIPE,
-                                  universal_newlines=True) as proc:
-                diff_output, _ = proc.communicate(difference.unified_diff)
+            diff_output = color_unified_diff(difference.unified_diff)
         else:
             diff_output = difference.unified_diff
         for line in diff_output.splitlines():

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git



More information about the Reproducible-commits mailing list