[diffoscope] 02/02: presenters: text: fix recursive indentation of headers
Ximin Luo
infinity0 at debian.org
Fri Jun 30 17:35:57 CEST 2017
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository diffoscope.
commit 9c0a3d222d0139611b47fa944d4df26cbdc0f735
Author: Ximin Luo <infinity0 at debian.org>
Date: Fri Jun 30 17:35:40 2017 +0200
presenters: text: fix recursive indentation of headers
---
diffoscope/presenters/text.py | 2 +-
tests/data/archive12.diff.txt | 15 +++++++++++++++
tests/test_presenters.py | 17 ++++++++---------
3 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/diffoscope/presenters/text.py b/diffoscope/presenters/text.py
index 7a16385..155ee79 100644
--- a/diffoscope/presenters/text.py
+++ b/diffoscope/presenters/text.py
@@ -89,5 +89,5 @@ class TextPresenter(Presenter):
def output(self, val, raw=False):
self.print_func(
- self.indent(val, self.PREFIX * (self.depth + 0 if raw else -1)),
+ self.indent(val, self.PREFIX * (self.depth + (0 if raw else -1))),
)
diff --git a/tests/data/archive12.diff.txt b/tests/data/archive12.diff.txt
new file mode 100644
index 0000000..4679511
--- /dev/null
+++ b/tests/data/archive12.diff.txt
@@ -0,0 +1,15 @@
+--- archive1.tar
++++ archive2.tar
+├── file list
+│ @@ -1 +1 @@
+│ --rw-r--r-- 0 lamby (1000) lamby (1000) 22 2017-03-19 22:26:58.000000 compressed.gz
+│ +-rw-r--r-- 0 lamby (1000) lamby (1000) 33 2017-03-19 22:27:42.000000 compressed.gz
+├── compressed.gz
+│ ├── metadata
+│ │ @@ -1 +1 @@
+│ │ -gzip compressed data, max compression, from Unix
+│ │ +gzip compressed data, was "compressed", last modified: Sun Mar 19 22:27:42 2017, max compression, from Unix
+│ ├── compressed
+│ │ @@ -1 +1 @@
+│ │ -a
+│ │ +b
diff --git a/tests/test_presenters.py b/tests/test_presenters.py
index b604cda..538c01c 100644
--- a/tests/test_presenters.py
+++ b/tests/test_presenters.py
@@ -29,9 +29,9 @@ from .utils.data import cwd_data, get_data
re_html = re.compile(r'.*<body(?P<body>.*)<div class="footer">', re.MULTILINE | re.DOTALL)
-def run(capsys, *args):
+def run(capsys, *args, pair=('test1.tar', 'test2.tar')):
with pytest.raises(SystemExit) as exc, cwd_data():
- main(args + ('test1.tar', 'test2.tar'))
+ main(args + pair)
out, err = capsys.readouterr()
assert err == ''
@@ -39,13 +39,7 @@ def run(capsys, *args):
return out
def run_images(capsys, *args):
- with pytest.raises(SystemExit) as exc, cwd_data():
- main(args + ('test1.png', 'test2.png'))
- out, err = capsys.readouterr()
-
- assert err == ''
- assert exc.value.code == 1
- return out
+ return run(capsys, *args, pair=('test1.png', 'test2.png'))
def extract_body(val):
"""
@@ -65,6 +59,11 @@ def test_text_option_is_default(capsys):
assert out == get_data('output.txt')
+def test_text_proper_indentation(capsys):
+ out = run(capsys, pair=('archive1.tar', 'archive2.tar'))
+
+ assert out == get_data('archive12.diff.txt')
+
def test_text_option_color(capsys):
out = run(capsys, '--text-color=always')
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list