From 1402a12f04691ef4db48dfb68d30d6292df2c4cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Wed, 1 Mar 2023 00:27:39 +0800 Subject: [PATCH] Simplified the logic in the add_txn function in testlib_txn.py. --- tests/testlib_txn.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/testlib_txn.py b/tests/testlib_txn.py index 1216fee..da675d2 100644 --- a/tests/testlib_txn.py +++ b/tests/testlib_txn.py @@ -393,10 +393,11 @@ def add_txn(client: httpx.Client, form: dict[str, str]) -> int: :return: The newly-added transaction ID. """ prefix: str = "/accounting/transactions" - txn_type: str \ - = "income" if len({x for x in form if "-debit-" in x}) == 0 else\ - ("expense" if len({x for x in form if "-credit-" in x}) == 0 else - "transfer") + txn_type: str = "transfer" + if len({x for x in form if "-debit-" in x}) == 0: + txn_type = "income" + elif len({x for x in form if "-credit-" in x}) == 0: + txn_type = "expense" store_uri = f"{prefix}/store/{txn_type}" response: httpx.Response = client.post(store_uri, data=form) assert response.status_code == 302