1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-10-15 19:35:45 +03:00
Files
openuds/server/conftest.py
Adolfo Gómez García 909991a963 Refactor and enhance codebase with various improvements
- Updated `pytest.ini` to ignore additional warnings: `PytestUnraisableExceptionWarning` and `ResourceWarning` for `sqlite3`.
- Added exception handling for `User.DoesNotExist` in `users_groups.py` to raise a `NotFound` exception.
- Modified pattern matching in `__init__.py` to improve clarity and correctness.
- Implemented equality method in `SchemaProperty` class in `api.py` for better comparison of schema properties.
- Enhanced type hints in `user_interface.py` for `as_choices` method to support more input types.
- Fixed key name from `row-style` to `row_style` in `test_users_groups_users.py`.
- Improved readability of assertions in `test_apigen.py` by formatting multi-line assertions.
- Deleted obsolete test file `test_helpdoc.py`.
- Updated imports in `test_gui.py` to include `types` for better type handling.
- Refactored query execution tests in `test_query_filter.py` to improve clarity and maintainability.
- Adjusted assertions in OpenStack helper tests to use object attributes instead of dictionary keys.
- Enhanced test assertions in `test_service_fixed.py` and `test_service_multi.py` for consistency.
- Updated Proxmox helper tests to use `ChoiceItem` type for better type checking.
- Added a new `conftest.py` file to manage database connections and garbage collection during tests.
2025-09-04 04:11:59 +02:00

29 lines
648 B
Python

import pytest
import gc
from django.db import connections
@pytest.fixture(autouse=True)
def close_all_db_connections():
yield
for conn in connections.all():
try:
conn.close()
except Exception:
pass
def pytest_sessionfinish(session: pytest.Session, exitstatus: pytest.ExitCode) -> None:
"""Al final de toda la suite, cerrar conexiones y forzar GC."""
try:
from django.db import connections
for conn in connections.all():
try:
conn.close()
except Exception:
pass
except ImportError:
pass
gc.collect()