Blob Blame History Raw
From 17846e821f3c979189003d8af6fdfc5301b94b85 Mon Sep 17 00:00:00 2001
From: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
Date: Fri, 10 Dec 2021 09:03:29 +0100
Subject: [PATCH 1/2] dist: Include invalid.txt needed by the test suite

---
 MANIFEST.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MANIFEST.in b/MANIFEST.in
index 2cdf363..b6467b1 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -5,6 +5,6 @@ include blockdiag.1
 include tox.ini
 include src/blockdiag/tests/VLGothic/*
 recursive-include examples blockdiagrc *.diag *.png *.svg
-recursive-include src README *.py *.diag *.gif *.png
+recursive-include src README *.py *.diag *.gif *.png invalid.txt
 
 exclude examples/update.sh

From 7a4ffa77789a0b3c202c78e5cf198bcf32754c15 Mon Sep 17 00:00:00 2001
From: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
Date: Fri, 10 Dec 2021 09:04:27 +0100
Subject: [PATCH 2/2] test: Skip tests requiring an internet access

Some build systems like Fedora's build packages in offline environments,
and trying to fetch remote resources results in test failures.
---
 src/blockdiag/tests/test_command.py          | 7 ++++++-
 src/blockdiag/tests/test_generate_diagram.py | 4 ++++
 tox.ini                                      | 2 +-
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/blockdiag/tests/test_command.py b/src/blockdiag/tests/test_command.py
index f5e8e56..d4bbb4e 100644
--- a/src/blockdiag/tests/test_command.py
+++ b/src/blockdiag/tests/test_command.py
@@ -14,12 +14,14 @@
 #  limitations under the License.
 
 import os
+import sys
 import unittest
 
 from blockdiag.command import BlockdiagApp
-from blockdiag.tests.utils import TemporaryDirectory
+from blockdiag.tests.utils import TemporaryDirectory, capture_stderr
 
 
+@capture_stderr
 class TestBlockdiagApp(unittest.TestCase):
     def test_app_cleans_up_images(self):
         testdir = os.path.dirname(__file__)
@@ -42,6 +44,9 @@ def cleanup():
             app.register_cleanup_handler(cleanup)  # to get internal state
             app.run(args)
 
+            if 'Could not retrieve:' in sys.stderr.getvalue():
+                raise unittest.SkipTest("No internet access")
+
             self.assertTrue(urlopen_cache)  # check images were cached
             for path in urlopen_cache.values():
                 self.assertFalse(os.path.exists(path))  # and removed finally
diff --git a/src/blockdiag/tests/test_generate_diagram.py b/src/blockdiag/tests/test_generate_diagram.py
index a212d89..37620e0 100644
--- a/src/blockdiag/tests/test_generate_diagram.py
+++ b/src/blockdiag/tests/test_generate_diagram.py
@@ -104,6 +104,8 @@ def generate(mainfunc, filetype, source, options):
 
         mainfunc(['--debug', '-T', filetype, '-o', tmpfile, source] +
                  list(options))
+        if 'Could not retrieve:' in sys.stderr.getvalue():
+            raise unittest.SkipTest("No internet access")
     finally:
         tmpdir.clean()
 
@@ -150,6 +152,8 @@ def ghostscript_not_found_test():
 
         args = ['-T', 'SVG', '-o', tmpfile, diagpath]
         ret = blockdiag.command.main(args)
+        if 'Could not retrieve:' in sys.stderr.getvalue():
+            raise unittest.SkipTest("No internet access")
         assert 'Could not convert image:' in sys.stderr.getvalue()
         assert ret == 0
     finally:
diff --git a/tox.ini b/tox.ini
index 0aafed8..e58c997 100644
--- a/tox.ini
+++ b/tox.ini
@@ -26,4 +26,4 @@ description =
 extras =
     testing
 commands =
-    flake8 src
+    flake8 --show-source src