From 42b62671fabfdcf983a9575221420d85f7fbcac1 Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Tue, 23 Sep 2025 07:44:37 -0400 Subject: New upstream version 1.30.8. --- test/test_extractor.py | 3 +++ test/test_postprocessor.py | 25 ++++++++++++++++++++++++- test/test_util.py | 3 +++ test/test_ytdl.py | 9 ++++----- 4 files changed, 34 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/test_extractor.py b/test/test_extractor.py index f8b8f09..a623e1d 100644 --- a/test/test_extractor.py +++ b/test/test_extractor.py @@ -156,6 +156,9 @@ class TestExtractorModule(unittest.TestCase): self.fail(f"{cls.__name__} pattern does not match " f"example URL '{cls.example}'") + self.assertEqual(cls, extr.__class__) + self.assertEqual(cls, extractor.find(cls.example).__class__) + extr.request = fail_request extr.initialize() extr.finalize() diff --git a/test/test_postprocessor.py b/test/test_postprocessor.py index 07bd348..2902fea 100644 --- a/test/test_postprocessor.py +++ b/test/test_postprocessor.py @@ -20,7 +20,7 @@ import collections from datetime import datetime sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from gallery_dl import extractor, output, path, util # noqa E402 +from gallery_dl import extractor, output, path, util, exception # noqa E402 from gallery_dl import postprocessor, config # noqa E402 from gallery_dl.postprocessor.common import PostProcessor # noqa E402 @@ -555,6 +555,17 @@ class MetadataTest(BasePostprocessorTest): test({"mode": "custom", "format": "{foo}\n{missing}\n"}) test({"format": "{foo}\n{missing}\n"}) + def test_metadata_mode_print(self): + self._create( + {"mode": "print", "format": "{foo}\n{missing}"}, + {"foo": "bar"}, + ) + + with patch("sys.stdout", Mock()) as m: + self._trigger() + + self.assertEqual(self._output(m), "bar\nNone\n") + def test_metadata_extfmt(self): pp = self._create({ "extension" : "ignored", @@ -867,6 +878,18 @@ class PythonTest(BasePostprocessorTest): self._trigger() self.assertEqual(self.pathfmt.kwdict["_result"], 24) + def test_eval(self): + self._create({"mode": "eval", "expression": "abort()"}) + + with self.assertRaises(exception.StopExtraction): + self._trigger() + + def test_eval_auto(self): + self._create({"expression": "abort()"}) + + with self.assertRaises(exception.StopExtraction): + self._trigger() + def _write_module(self, path): with open(path, "w") as fp: fp.write(""" diff --git a/test/test_util.py b/test/test_util.py index 4a76769..bfaab01 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -1041,6 +1041,9 @@ value = 123 self.assertEqual(response.links.get("next"), None) self.assertEqual(response.close(), None) + with response as ctx: + self.assertIs(response, ctx) + class TestExtractor(): category = "test_category" diff --git a/test/test_ytdl.py b/test/test_ytdl.py index 88933e4..1f28c9a 100644 --- a/test/test_ytdl.py +++ b/test/test_ytdl.py @@ -42,8 +42,6 @@ class Test_CommandlineArguments(unittest.TestCase): def test_proxy(self): self._(["--proxy", "socks5://127.0.0.1:1080/"], "proxy", "socks5://127.0.0.1:1080/") - self._(["--cn-verification-proxy", "https://127.0.0.1"], - "cn_verification_proxy", "https://127.0.0.1") self._(["--geo-verification-proxy", "127.0.0.1"], "geo_verification_proxy", "127.0.0.1") @@ -105,7 +103,10 @@ class Test_CommandlineArguments(unittest.TestCase): "geo_bypass_ip_block", "198.51.100.14/24") def test_headers(self): - headers = self.module.std_headers + try: + headers = self.module.utils.networking.std_headers + except AttributeError: + headers = self.module.std_headers self.assertNotEqual(headers["User-Agent"], "Foo/1.0") self._(["--user-agent", "Foo/1.0"]) @@ -194,8 +195,6 @@ class Test_CommandlineArguments(unittest.TestCase): }) def test_xattr(self): - self._("--xattr-set-filesize", "xattr_set_filesize", True) - opts = self._("--xattrs") self.assertEqual(opts["postprocessors"][0], {"key": "XAttrMetadata"}) -- cgit v1.2.3