Moved dropping tables from the setUp method to the test_init test in the ConsoleCommandTestCase test case. The other tests may not need to drop the tables first.

This commit is contained in:
依瑪貓 2023-07-29 11:57:44 +08:00
parent 545f49043b
commit 0614457b7b

View File

@ -44,6 +44,11 @@ class ConsoleCommandTestCase(unittest.TestCase):
self.__app: Flask = create_test_app() self.__app: Flask = create_test_app()
"""The Flask application.""" """The Flask application."""
def test_init(self) -> None:
"""Tests the "accounting-init" console command.
:return: None.
"""
with self.__app.app_context(): with self.__app.app_context():
# Drop every accounting table, to see if accounting-init recreates # Drop every accounting table, to see if accounting-init recreates
# them correctly. # them correctly.
@ -58,11 +63,6 @@ class ConsoleCommandTestCase(unittest.TestCase):
if x.startswith("accounting_")}), if x.startswith("accounting_")}),
0) 0)
def test_init(self) -> None:
"""Tests the "accounting-init" console command.
:return: None.
"""
runner: FlaskCliRunner = self.__app.test_cli_runner() runner: FlaskCliRunner = self.__app.test_cli_runner()
with self.__app.app_context(): with self.__app.app_context():
result: Result = runner.invoke( result: Result = runner.invoke(