From b3fa52584ed1d9e67eb8f21b4e9b90c29af91fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sat, 10 Jun 2023 10:32:33 +0800 Subject: [PATCH] Revised the code to read from the CSV data files in the __test_base_account_data method of the ConsoleCommandTestCase test case, to prevent PyCharm from complaining. --- tests/test_commands.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/test_commands.py b/tests/test_commands.py index c21ad9d..d988081 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -81,12 +81,13 @@ class ConsoleCommandTestCase(unittest.TestCase): from accounting.models import BaseAccount with open(data_dir / "base_accounts.csv") as fp: - data: dict[dict[str, Any]] \ - = {x["code"]: {"code": x["code"], - "title": x["title"], - "l10n": {y[5:]: x[y] - for y in x if y.startswith("l10n-")}} - for x in csv.DictReader(fp)} + rows: list[dict[str, str]] = list(csv.DictReader(fp)) + data: dict[dict[str, Any]] \ + = {x["code"]: {"code": x["code"], + "title": x["title"], + "l10n": {y[5:]: x[y] + for y in x if y.startswith("l10n-")}} + for x in rows} with self.__app.app_context(): accounts: list[BaseAccount] = BaseAccount.query.all()