From 4a4ab2d165ad97ddee951d66796a375be33562e5 Mon Sep 17 00:00:00 2001 From: Wolfgang Fahl Date: Fri, 8 Nov 2024 15:11:40 +0100 Subject: [PATCH] fixes test for issue 111 --- tests/test_wikiquery.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/test_wikiquery.py b/tests/test_wikiquery.py index 559454a..f88ded4 100644 --- a/tests/test_wikiquery.py +++ b/tests/test_wikiquery.py @@ -3,7 +3,7 @@ @author: wf """ - +import re import json import unittest from contextlib import redirect_stdout @@ -191,10 +191,16 @@ def test_issue111(self): mystdout = StringIO() with redirect_stdout(mystdout): mainQuery(argv) - res = mystdout.getvalue() - if self.debug: - print(res) - records=json.loads(res) + text = mystdout.getvalue() + debug=self.debug + #debug=True + json_text = re.search(r'\{.*', text, re.DOTALL).group(0) + if debug: + print(json_text) + records=json.loads(json_text) + self.assertGreaterEqual(len(records["data"]),3) + for record in records["data"]: + self.assertIn("name", record) pass