Add db.engine.dispose() in test tearDown to fix ResourceWarning from Python 3.13.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# The Mia! Accounting Project.
|
# The Mia! Accounting Project.
|
||||||
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/1
|
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/1
|
||||||
|
|
||||||
# Copyright (c) 2023 imacat.
|
# Copyright (c) 2023-2026 imacat.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -105,6 +105,15 @@ class AccountTestCase(unittest.TestCase):
|
|||||||
self.assertEqual(response.headers["Location"],
|
self.assertEqual(response.headers["Location"],
|
||||||
f"{PREFIX}/{BANK.code}")
|
f"{PREFIX}/{BANK.code}")
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
"""Tears down the test.
|
||||||
|
This is run once per test.
|
||||||
|
|
||||||
|
:return: None.
|
||||||
|
"""
|
||||||
|
with self.__app.app_context():
|
||||||
|
db.engine.dispose()
|
||||||
|
|
||||||
def test_nobody(self) -> None:
|
def test_nobody(self) -> None:
|
||||||
"""Test the permission as nobody.
|
"""Test the permission as nobody.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# The Mia! Accounting Project.
|
# The Mia! Accounting Project.
|
||||||
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/1/26
|
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/1/26
|
||||||
|
|
||||||
# Copyright (c) 2023 imacat.
|
# Copyright (c) 2023-2026 imacat.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -22,6 +22,7 @@ import unittest
|
|||||||
import httpx
|
import httpx
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
|
||||||
|
from test_site import db
|
||||||
from testlib import create_test_app, get_client
|
from testlib import create_test_app, get_client
|
||||||
|
|
||||||
LIST_URI: str = "/accounting/base-accounts"
|
LIST_URI: str = "/accounting/base-accounts"
|
||||||
@@ -42,6 +43,15 @@ class BaseAccountTestCase(unittest.TestCase):
|
|||||||
self.__app: Flask = create_test_app()
|
self.__app: Flask = create_test_app()
|
||||||
"""The Flask application."""
|
"""The Flask application."""
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
"""Tears down the test.
|
||||||
|
This is run once per test.
|
||||||
|
|
||||||
|
:return: None.
|
||||||
|
"""
|
||||||
|
with self.__app.app_context():
|
||||||
|
db.engine.dispose()
|
||||||
|
|
||||||
def test_nobody(self) -> None:
|
def test_nobody(self) -> None:
|
||||||
"""Test the permission as nobody.
|
"""Test the permission as nobody.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# The Mia! Accounting Project.
|
# The Mia! Accounting Project.
|
||||||
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/4/10
|
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/4/10
|
||||||
|
|
||||||
# Copyright (c) 2023 imacat.
|
# Copyright (c) 2023-2026 imacat.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -45,6 +45,15 @@ class ConsoleCommandTestCase(unittest.TestCase):
|
|||||||
self.__app: Flask = create_test_app()
|
self.__app: Flask = create_test_app()
|
||||||
"""The Flask application."""
|
"""The Flask application."""
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
"""Tears down the test.
|
||||||
|
This is run once per test.
|
||||||
|
|
||||||
|
:return: None.
|
||||||
|
"""
|
||||||
|
with self.__app.app_context():
|
||||||
|
db.engine.dispose()
|
||||||
|
|
||||||
def test_init_db(self) -> None:
|
def test_init_db(self) -> None:
|
||||||
"""Tests the "accounting-init-db" console command.
|
"""Tests the "accounting-init-db" console command.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# The Mia! Accounting Project.
|
# The Mia! Accounting Project.
|
||||||
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/1
|
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/1
|
||||||
|
|
||||||
# Copyright (c) 2023 imacat.
|
# Copyright (c) 2023-2026 imacat.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -94,6 +94,15 @@ class CurrencyTestCase(unittest.TestCase):
|
|||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
self.assertEqual(response.headers["Location"], f"{PREFIX}/{EUR.code}")
|
self.assertEqual(response.headers["Location"], f"{PREFIX}/{EUR.code}")
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
"""Tears down the test.
|
||||||
|
This is run once per test.
|
||||||
|
|
||||||
|
:return: None.
|
||||||
|
"""
|
||||||
|
with self.__app.app_context():
|
||||||
|
db.engine.dispose()
|
||||||
|
|
||||||
def test_nobody(self) -> None:
|
def test_nobody(self) -> None:
|
||||||
"""Test the permission as nobody.
|
"""Test the permission as nobody.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# The Mia! Accounting Project.
|
# The Mia! Accounting Project.
|
||||||
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/28
|
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/28
|
||||||
|
|
||||||
# Copyright (c) 2023 imacat.
|
# Copyright (c) 2023-2026 imacat.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -24,6 +24,7 @@ import httpx
|
|||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
|
||||||
from accounting.utils.next_uri import encode_next
|
from accounting.utils.next_uri import encode_next
|
||||||
|
from test_site import db
|
||||||
from testlib import NEXT_URI, Accounts, create_test_app, get_client, \
|
from testlib import NEXT_URI, Accounts, create_test_app, get_client, \
|
||||||
get_csrf_token, add_journal_entry
|
get_csrf_token, add_journal_entry
|
||||||
|
|
||||||
@@ -52,6 +53,15 @@ class DescriptionEditorTestCase(unittest.TestCase):
|
|||||||
self.__csrf_token: str = get_csrf_token(self.__client)
|
self.__csrf_token: str = get_csrf_token(self.__client)
|
||||||
"""The CSRF token."""
|
"""The CSRF token."""
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
"""Tears down the test.
|
||||||
|
This is run once per test.
|
||||||
|
|
||||||
|
:return: None.
|
||||||
|
"""
|
||||||
|
with self.__app.app_context():
|
||||||
|
db.engine.dispose()
|
||||||
|
|
||||||
def test_description_editor(self) -> None:
|
def test_description_editor(self) -> None:
|
||||||
"""Test the description editor.
|
"""Test the description editor.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# The Mia! Accounting Project.
|
# The Mia! Accounting Project.
|
||||||
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/24
|
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/24
|
||||||
|
|
||||||
# Copyright (c) 2023 imacat.
|
# Copyright (c) 2023-2026 imacat.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -63,6 +63,15 @@ class CashReceiptJournalEntryTestCase(unittest.TestCase):
|
|||||||
self.__csrf_token: str = get_csrf_token(self.__client)
|
self.__csrf_token: str = get_csrf_token(self.__client)
|
||||||
"""The CSRF token."""
|
"""The CSRF token."""
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
"""Tears down the test.
|
||||||
|
This is run once per test.
|
||||||
|
|
||||||
|
:return: None.
|
||||||
|
"""
|
||||||
|
with self.__app.app_context():
|
||||||
|
db.engine.dispose()
|
||||||
|
|
||||||
def test_nobody(self) -> None:
|
def test_nobody(self) -> None:
|
||||||
"""Test the permission as nobody.
|
"""Test the permission as nobody.
|
||||||
|
|
||||||
@@ -688,6 +697,15 @@ class CashDisbursementJournalEntryTestCase(unittest.TestCase):
|
|||||||
self.__csrf_token: str = get_csrf_token(self.__client)
|
self.__csrf_token: str = get_csrf_token(self.__client)
|
||||||
"""The CSRF token."""
|
"""The CSRF token."""
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
"""Tears down the test.
|
||||||
|
This is run once per test.
|
||||||
|
|
||||||
|
:return: None.
|
||||||
|
"""
|
||||||
|
with self.__app.app_context():
|
||||||
|
db.engine.dispose()
|
||||||
|
|
||||||
def test_nobody(self) -> None:
|
def test_nobody(self) -> None:
|
||||||
"""Test the permission as nobody.
|
"""Test the permission as nobody.
|
||||||
|
|
||||||
@@ -1289,6 +1307,15 @@ class TransferJournalEntryTestCase(unittest.TestCase):
|
|||||||
self.__csrf_token: str = get_csrf_token(self.__client)
|
self.__csrf_token: str = get_csrf_token(self.__client)
|
||||||
"""The CSRF token."""
|
"""The CSRF token."""
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
"""Tears down the test.
|
||||||
|
This is run once per test.
|
||||||
|
|
||||||
|
:return: None.
|
||||||
|
"""
|
||||||
|
with self.__app.app_context():
|
||||||
|
db.engine.dispose()
|
||||||
|
|
||||||
def test_nobody(self) -> None:
|
def test_nobody(self) -> None:
|
||||||
"""Test the permission as nobody.
|
"""Test the permission as nobody.
|
||||||
|
|
||||||
@@ -2169,6 +2196,15 @@ class JournalEntryReorderTestCase(unittest.TestCase):
|
|||||||
self.__csrf_token: str = get_csrf_token(self.__client)
|
self.__csrf_token: str = get_csrf_token(self.__client)
|
||||||
"""The CSRF token."""
|
"""The CSRF token."""
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
"""Tears down the test.
|
||||||
|
This is run once per test.
|
||||||
|
|
||||||
|
:return: None.
|
||||||
|
"""
|
||||||
|
with self.__app.app_context():
|
||||||
|
db.engine.dispose()
|
||||||
|
|
||||||
def test_change_date(self) -> None:
|
def test_change_date(self) -> None:
|
||||||
"""Tests to change the date of a journal entry.
|
"""Tests to change the date of a journal entry.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# The Mia! Accounting Project.
|
# The Mia! Accounting Project.
|
||||||
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/11
|
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/11
|
||||||
|
|
||||||
# Copyright (c) 2023 imacat.
|
# Copyright (c) 2023-2026 imacat.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -63,6 +63,15 @@ class OffsetTestCase(unittest.TestCase):
|
|||||||
"""The offset test data."""
|
"""The offset test data."""
|
||||||
self.__data.populate()
|
self.__data.populate()
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
"""Tears down the test.
|
||||||
|
This is run once per test.
|
||||||
|
|
||||||
|
:return: None.
|
||||||
|
"""
|
||||||
|
with self.__app.app_context():
|
||||||
|
db.engine.dispose()
|
||||||
|
|
||||||
def test_add_receivable_offset(self) -> None:
|
def test_add_receivable_offset(self) -> None:
|
||||||
"""Tests to add the receivable offset.
|
"""Tests to add the receivable offset.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# The Mia! Accounting Project.
|
# The Mia! Accounting Project.
|
||||||
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/22
|
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/22
|
||||||
|
|
||||||
# Copyright (c) 2023 imacat.
|
# Copyright (c) 2023-2026 imacat.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -55,6 +55,15 @@ class OptionTestCase(unittest.TestCase):
|
|||||||
self.__csrf_token: str = get_csrf_token(self.__client)
|
self.__csrf_token: str = get_csrf_token(self.__client)
|
||||||
"""The CSRF token."""
|
"""The CSRF token."""
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
"""Tears down the test.
|
||||||
|
This is run once per test.
|
||||||
|
|
||||||
|
:return: None.
|
||||||
|
"""
|
||||||
|
with self.__app.app_context():
|
||||||
|
db.engine.dispose()
|
||||||
|
|
||||||
def test_nobody(self) -> None:
|
def test_nobody(self) -> None:
|
||||||
"""Test the permission as nobody.
|
"""Test the permission as nobody.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# The Mia! Accounting Project.
|
# The Mia! Accounting Project.
|
||||||
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/4/9
|
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/4/9
|
||||||
|
|
||||||
# Copyright (c) 2023 imacat.
|
# Copyright (c) 2023-2026 imacat.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -23,6 +23,7 @@ import unittest
|
|||||||
import httpx
|
import httpx
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
|
||||||
|
from test_site import db
|
||||||
from test_site.lib import BaseTestData
|
from test_site.lib import BaseTestData
|
||||||
from testlib import create_test_app, get_client, get_csrf_token, Accounts
|
from testlib import create_test_app, get_client, get_csrf_token, Accounts
|
||||||
|
|
||||||
@@ -54,6 +55,15 @@ class ReportTestCase(unittest.TestCase):
|
|||||||
self.__csrf_token: str = get_csrf_token(self.__client)
|
self.__csrf_token: str = get_csrf_token(self.__client)
|
||||||
"""The CSRF token."""
|
"""The CSRF token."""
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
"""Tears down the test.
|
||||||
|
This is run once per test.
|
||||||
|
|
||||||
|
:return: None.
|
||||||
|
"""
|
||||||
|
with self.__app.app_context():
|
||||||
|
db.engine.dispose()
|
||||||
|
|
||||||
def test_nobody(self) -> None:
|
def test_nobody(self) -> None:
|
||||||
"""Test the permission as nobody.
|
"""Test the permission as nobody.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# The Mia! Accounting Project.
|
# The Mia! Accounting Project.
|
||||||
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/4/8
|
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/4/8
|
||||||
|
|
||||||
# Copyright (c) 2023 imacat.
|
# Copyright (c) 2023-2026 imacat.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -57,6 +57,15 @@ class UnmatchedOffsetTestCase(unittest.TestCase):
|
|||||||
self.__csrf_token: str = get_csrf_token(self.__client)
|
self.__csrf_token: str = get_csrf_token(self.__client)
|
||||||
"""The CSRF token."""
|
"""The CSRF token."""
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
"""Tears down the test.
|
||||||
|
This is run once per test.
|
||||||
|
|
||||||
|
:return: None.
|
||||||
|
"""
|
||||||
|
with self.__app.app_context():
|
||||||
|
db.engine.dispose()
|
||||||
|
|
||||||
def test_nobody(self) -> None:
|
def test_nobody(self) -> None:
|
||||||
"""Test the permission as nobody.
|
"""Test the permission as nobody.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# The Mia! Accounting Project.
|
# The Mia! Accounting Project.
|
||||||
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/3
|
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/3
|
||||||
|
|
||||||
# Copyright (c) 2023 imacat.
|
# Copyright (c) 2023-2026 imacat.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -27,6 +27,7 @@ from accounting.utils.next_uri import append_next, inherit_next, or_next, \
|
|||||||
encode_next, decode_next
|
encode_next, decode_next
|
||||||
from accounting.utils.pagination import Pagination, DEFAULT_PAGE_SIZE
|
from accounting.utils.pagination import Pagination, DEFAULT_PAGE_SIZE
|
||||||
from accounting.utils.query import parse_query_keywords
|
from accounting.utils.query import parse_query_keywords
|
||||||
|
from test_site import db
|
||||||
from testlib import TEST_SERVER, create_test_app, get_csrf_token, NEXT_URI
|
from testlib import TEST_SERVER, create_test_app, get_csrf_token, NEXT_URI
|
||||||
|
|
||||||
|
|
||||||
@@ -43,6 +44,15 @@ class NextUriTestCase(unittest.TestCase):
|
|||||||
self.__app: Flask = create_test_app()
|
self.__app: Flask = create_test_app()
|
||||||
"""The Flask application."""
|
"""The Flask application."""
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
"""Tears down the test.
|
||||||
|
This is run once per test.
|
||||||
|
|
||||||
|
:return: None.
|
||||||
|
"""
|
||||||
|
with self.__app.app_context():
|
||||||
|
db.engine.dispose()
|
||||||
|
|
||||||
def test_next_uri(self) -> None:
|
def test_next_uri(self) -> None:
|
||||||
"""Tests the next URI utilities with the next URI.
|
"""Tests the next URI utilities with the next URI.
|
||||||
|
|
||||||
@@ -236,6 +246,15 @@ class PaginationTestCase(unittest.TestCase):
|
|||||||
"""The user client."""
|
"""The user client."""
|
||||||
self.__client.headers["Referer"] = TEST_SERVER
|
self.__client.headers["Referer"] = TEST_SERVER
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
"""Tears down the test.
|
||||||
|
This is run once per test.
|
||||||
|
|
||||||
|
:return: None.
|
||||||
|
"""
|
||||||
|
with self.__app.app_context():
|
||||||
|
db.engine.dispose()
|
||||||
|
|
||||||
def __test_success(self, query: str, items: range,
|
def __test_success(self, query: str, items: range,
|
||||||
result: range, is_paged: bool = True,
|
result: range, is_paged: bool = True,
|
||||||
is_reversed: bool | None = None) -> None:
|
is_reversed: bool | None = None) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user