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.

This commit is contained in:
依瑪貓 2023-06-10 10:32:33 +08:00
parent 17acf5efd7
commit 636bd2891f

View File

@ -81,12 +81,13 @@ class ConsoleCommandTestCase(unittest.TestCase):
from accounting.models import BaseAccount from accounting.models import BaseAccount
with open(data_dir / "base_accounts.csv") as fp: with open(data_dir / "base_accounts.csv") as fp:
rows: list[dict[str, str]] = list(csv.DictReader(fp))
data: dict[dict[str, Any]] \ data: dict[dict[str, Any]] \
= {x["code"]: {"code": x["code"], = {x["code"]: {"code": x["code"],
"title": x["title"], "title": x["title"],
"l10n": {y[5:]: x[y] "l10n": {y[5:]: x[y]
for y in x if y.startswith("l10n-")}} for y in x if y.startswith("l10n-")}}
for x in csv.DictReader(fp)} for x in rows}
with self.__app.app_context(): with self.__app.app_context():
accounts: list[BaseAccount] = BaseAccount.query.all() accounts: list[BaseAccount] = BaseAccount.query.all()