mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-07 20:58:27 +08:00
Clean up build logs after each test so that it doesn't affect tests run later
Tests in test_build.py started to affect tests in test_content_generator.py after test_content_generator.py was moved, which caused those tests to execute after test_build.py
This commit is contained in:
@@ -5,6 +5,7 @@ import os
|
||||
import pytest
|
||||
|
||||
from datetime import datetime
|
||||
import mock
|
||||
|
||||
import module_build_service
|
||||
from module_build_service.builder.utils import get_rpm_release
|
||||
@@ -379,3 +380,19 @@ def reuse_shared_userspace_init_data():
|
||||
|
||||
db_session.add(module_build)
|
||||
db_session.commit()
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def cleanup_build_logs(request):
|
||||
"""
|
||||
Clean up any build logs remaining after each test so that it doesn't affect tests run later.
|
||||
"""
|
||||
|
||||
def _cleanup_build_logs():
|
||||
build_ids = list(module_build_service.build_logs.handlers.keys())
|
||||
for build_id in build_ids:
|
||||
mock_build = mock.Mock()
|
||||
mock_build.id = build_id
|
||||
module_build_service.build_logs.stop(mock_build)
|
||||
|
||||
request.addfinalizer(_cleanup_build_logs)
|
||||
|
||||
Reference in New Issue
Block a user