[job] add 'output.jsonl' option (#8953)

This commit is contained in:
Mike Fährmann
2026-01-30 08:34:24 +01:00
parent 532ab7112e
commit 3445c51ca4
4 changed files with 48 additions and 5 deletions

View File

@@ -359,6 +359,25 @@ class TestDataJob(TestJob):
self.assertEqual(tjob.data[-1][0], Message.Url)
self.assertEqual(tjob.data[-1][2]["num"], "3")
def test_jsonl(self):
extr = TestExtractor.from_url("test:")
tjob = self.jobclass(extr, file=io.StringIO())
with patch("gallery_dl.job.DataJob.out") as out:
tjob.run()
self.assertEqual(len(out.call_args_list), 0)
config.set(("output",), "jsonl", True)
extr = TestExtractor.from_url("test:")
file = io.StringIO()
tjob = self.jobclass(extr, file=file)
with patch("gallery_dl.job.DataJob.out") as out:
tjob.run()
self.assertEqual(len(out.call_args_list), 4)
tjob.run()
for line in file.getvalue().split():
self.assertRegex(line, r"""^\[[23],("http[^"]+",)?\{.+\}\]$""")
class TestExtractor(Extractor):
category = "test_category"