chore: update development dependencies and improve test coverage
Some checks failed
CI / lint-and-test (push) Failing after 11s
Some checks failed
CI / lint-and-test (push) Failing after 11s
- Upgraded `pytest-asyncio` to version 1.0 to ensure compatibility with the latest features and improvements. - Increased the coverage threshold in pytest configuration to 80%, enhancing the quality assurance process. - Added a new `conftest.py` file to manage shared fixtures and improve test organization. - Introduced multiple new test files to cover various components, ensuring comprehensive test coverage across the application. - Updated the `.coverage` file to reflect the latest coverage metrics.
This commit is contained in:
@@ -20,17 +20,23 @@ def db_url():
|
||||
return "sqlite:///:memory:"
|
||||
|
||||
|
||||
def _dispose_global_engine(session_module):
|
||||
"""Dispose global engine so connections are closed, then clear cache."""
|
||||
if session_module._engine is not None:
|
||||
session_module._engine.dispose()
|
||||
session_module._engine = None
|
||||
session_module._SessionLocal = None
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _reset_db_session(db_url):
|
||||
"""Ensure each test uses a fresh engine for :memory: (clear global cache for test URL)."""
|
||||
import duty_teller.db.session as session_module
|
||||
|
||||
session_module._engine = None
|
||||
session_module._SessionLocal = None
|
||||
_dispose_global_engine(session_module)
|
||||
init_db(db_url)
|
||||
yield
|
||||
session_module._engine = None
|
||||
session_module._SessionLocal = None
|
||||
_dispose_global_engine(session_module)
|
||||
|
||||
|
||||
def test_import_creates_users_and_duties(db_url):
|
||||
|
||||
Reference in New Issue
Block a user