[diffoscope] 01/01: tests: Actually compare the output of text/ReST/markdown formats to a fixture.

Chris Lamb chris at chris-lamb.co.uk
Sat Jan 21 06:12:08 CET 2017


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

lamby pushed a commit to branch lamby/output-formats
in repository diffoscope.

commit a5fe3cc05e81eba12b4db71cae7c158eddfbd917
Author: Chris Lamb <lamby at debian.org>
Date:   Sat Jan 21 16:07:39 2017 +1100

    tests: Actually compare the output of text/ReST/markdown formats to a fixture.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 tests/data/output.md     | 38 +++++++++++++++++++++++++++++++++++
 tests/data/output.rst    | 52 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/data/output.txt    | 34 +++++++++++++++++++++++++++++++
 tests/test_presenters.py | 12 +++++------
 4 files changed, 130 insertions(+), 6 deletions(-)

diff --git a/tests/data/output.md b/tests/data/output.md
new file mode 100644
index 0000000..a147d58
--- /dev/null
+++ b/tests/data/output.md
@@ -0,0 +1,38 @@
+# Comparing test1.tar & test2.tar
+
+## file list
+
+    @@ -1,4 +1,4 @@
+    -drwxr-xr-x   0 lunar     (1000) lunar     (1000)        0 2015-06-29 15:49:09.000000 dir/
+    --rw-r--r--   0 lunar     (1000) lunar     (1000)      446 2015-06-29 15:49:09.000000 dir/text
+    -crw-r--r--   0 root         (0) root         (0)    1,  3 2015-06-29 15:49:09.000000 dir/null
+    -lrwxrwxrwx   0 lunar     (1000) lunar     (1000)        0 2015-06-29 15:49:09.000000 dir/link -> broken
+    +drwxr-xr-x   0 lunar     (1000) lunar     (1000)        0 2015-06-29 15:49:41.000000 dir/
+    +-rw-r--r--   0 lunar     (1000) lunar     (1000)      671 2015-06-29 15:49:41.000000 dir/text
+    +crw-r--r--   0 root         (0) root         (0)    1,  3 2015-06-29 15:49:41.000000 dir/null
+    +lrwxrwxrwx   0 lunar     (1000) lunar     (1000)        0 2015-06-29 15:49:41.000000 dir/link -> really-broken
+
+## dir/text
+
+    @@ -1,6 +1,12 @@
+    +A common form of lorem ipsum reads:
+    +
+     Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
+     incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
+     nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+     Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
+     fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
+     culpa qui officia deserunt mollit anim id est laborum.
+    +
+    +"Lorem ipsum" text is derived from sections 1.10.32--3 of Cicero's De finibus
+    +bonorum et malorum (On the Ends of Goods and Evils, or alternatively [About]
+    +The Purposes of Good and Evil).
+
+## dir/link
+
+symlink
+
+    @@ -1 +1 @@
+    -destination: broken
+    +destination: really-broken
+
diff --git a/tests/data/output.rst b/tests/data/output.rst
new file mode 100644
index 0000000..08e60e3
--- /dev/null
+++ b/tests/data/output.rst
@@ -0,0 +1,52 @@
+===============================
+Comparing test1.tar & test2.tar
+===============================
+
+---------
+file list
+---------
+
+::
+
+    @@ -1,4 +1,4 @@
+    -drwxr-xr-x   0 lunar     (1000) lunar     (1000)        0 2015-06-29 15:49:09.000000 dir/
+    --rw-r--r--   0 lunar     (1000) lunar     (1000)      446 2015-06-29 15:49:09.000000 dir/text
+    -crw-r--r--   0 root         (0) root         (0)    1,  3 2015-06-29 15:49:09.000000 dir/null
+    -lrwxrwxrwx   0 lunar     (1000) lunar     (1000)        0 2015-06-29 15:49:09.000000 dir/link -> broken
+    +drwxr-xr-x   0 lunar     (1000) lunar     (1000)        0 2015-06-29 15:49:41.000000 dir/
+    +-rw-r--r--   0 lunar     (1000) lunar     (1000)      671 2015-06-29 15:49:41.000000 dir/text
+    +crw-r--r--   0 root         (0) root         (0)    1,  3 2015-06-29 15:49:41.000000 dir/null
+    +lrwxrwxrwx   0 lunar     (1000) lunar     (1000)        0 2015-06-29 15:49:41.000000 dir/link -> really-broken
+
+--------
+dir/text
+--------
+
+::
+
+    @@ -1,6 +1,12 @@
+    +A common form of lorem ipsum reads:
+    +
+     Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
+     incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
+     nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+     Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
+     fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
+     culpa qui officia deserunt mollit anim id est laborum.
+    +
+    +"Lorem ipsum" text is derived from sections 1.10.32--3 of Cicero's De finibus
+    +bonorum et malorum (On the Ends of Goods and Evils, or alternatively [About]
+    +The Purposes of Good and Evil).
+
+--------
+dir/link
+--------
+
+
+symlink
+::
+
+    @@ -1 +1 @@
+    -destination: broken
+    +destination: really-broken
+
diff --git a/tests/data/output.txt b/tests/data/output.txt
new file mode 100644
index 0000000..b515c2c
--- /dev/null
+++ b/tests/data/output.txt
@@ -0,0 +1,34 @@
+--- test1.tar
++++ test2.tar
+├── file list
+│ @@ -1,4 +1,4 @@
+│ -drwxr-xr-x   0 lunar     (1000) lunar     (1000)        0 2015-06-29 15:49:09.000000 dir/
+│ --rw-r--r--   0 lunar     (1000) lunar     (1000)      446 2015-06-29 15:49:09.000000 dir/text
+│ -crw-r--r--   0 root         (0) root         (0)    1,  3 2015-06-29 15:49:09.000000 dir/null
+│ -lrwxrwxrwx   0 lunar     (1000) lunar     (1000)        0 2015-06-29 15:49:09.000000 dir/link -> broken
+│ +drwxr-xr-x   0 lunar     (1000) lunar     (1000)        0 2015-06-29 15:49:41.000000 dir/
+│ +-rw-r--r--   0 lunar     (1000) lunar     (1000)      671 2015-06-29 15:49:41.000000 dir/text
+│ +crw-r--r--   0 root         (0) root         (0)    1,  3 2015-06-29 15:49:41.000000 dir/null
+│ +lrwxrwxrwx   0 lunar     (1000) lunar     (1000)        0 2015-06-29 15:49:41.000000 dir/link -> really-broken
+│ 
+├── dir/text
+│ @@ -1,6 +1,12 @@
+│ +A common form of lorem ipsum reads:
+│ +
+│  Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
+│  incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
+│  nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+│  Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
+│  fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
+│  culpa qui officia deserunt mollit anim id est laborum.
+│ +
+│ +"Lorem ipsum" text is derived from sections 1.10.32--3 of Cicero's De finibus
+│ +bonorum et malorum (On the Ends of Goods and Evils, or alternatively [About]
+│ +The Purposes of Good and Evil).
+│ 
+├── dir/link
+│┄ symlink
+│ @@ -1 +1 @@
+│ -destination: broken
+│ +destination: really-broken
+│ 
diff --git a/tests/test_presenters.py b/tests/test_presenters.py
index 8dd537f..8d30756 100644
--- a/tests/test_presenters.py
+++ b/tests/test_presenters.py
@@ -52,29 +52,29 @@ def test_text_option_with_file(tmpdir, capsys):
     out = run(capsys, '--text', report_path)
 
     assert out == ''
+
     with open(report_path, 'r', encoding='utf-8') as f:
-        assert f.read().startswith('--- ')
+        assert f.read() == data('output.txt')
 
 def test_text_option_with_stdiout(capsys):
     out = run(capsys, '--text', '-')
 
-    assert out.startswith('--- ')
+    assert out == data('output.txt')
 
 def test_markdown(capsys):
     out = run(capsys, '--markdown', '-')
 
-    assert out.startswith('# Comparing')
+    assert out == data('output.md')
 
 def test_restructuredtext(capsys):
     out = run(capsys, '--restructured-text', '-')
 
-    assert out.startswith('=====')
-    assert "Comparing" in out
+    assert out == data('output.rst')
 
 def test_no_report_option(capsys):
     out = run(capsys)
 
-    assert out.startswith('--- ')
+    assert out == data('output.txt')
 
 def test_html_option_with_file(tmpdir, capsys):
     report_path = str(tmpdir.join('report.html'))

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


More information about the diffoscope mailing list