From 8f2c1da0418a4c38aeef7de244e38aaf94ca14dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 8 May 2020 21:48:47 +0200 Subject: [PATCH] skip example config tests if files are not available (#730) --- test/test_config.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/test_config.py b/test/test_config.py index cb202be2..4171435f 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -14,7 +14,8 @@ import unittest import json import tempfile -sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +ROOTDIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.insert(0, ROOTDIR) from gallery_dl import config # noqa E402 @@ -156,10 +157,12 @@ class TestConfigFiles(unittest.TestCase): @staticmethod def _load(name): - rootdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - path = os.path.join(rootdir, "docs", name) - with open(path) as fp: - return json.load(fp) + path = os.path.join(ROOTDIR, "docs", name) + try: + with open(path) as fp: + return json.load(fp) + except FileNotFoundError: + raise unittest.SkipTest(path + " not available") if __name__ == '__main__':