[pp:python] add '"mode": "eval"'

This commit is contained in:
Mike Fährmann
2025-09-22 16:54:50 +02:00
parent b49745d351
commit 2480ba2a55
3 changed files with 56 additions and 6 deletions

View File

@@ -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
@@ -867,6 +867,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("""