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 0ae00bce79
commit 6723077b72

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:
data: dict[dict[str, Any]] \ rows: list[dict[str, str]] = list(csv.DictReader(fp))
= {x["code"]: {"code": x["code"], data: dict[dict[str, Any]] \
"title": x["title"], = {x["code"]: {"code": x["code"],
"l10n": {y[5:]: x[y] "title": x["title"],
for y in x if y.startswith("l10n-")}} "l10n": {y[5:]: x[y]
for x in csv.DictReader(fp)} for y in x if y.startswith("l10n-")}}
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()