Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create file monitoring fixture handler #1833

Merged
merged 4 commits into from
Sep 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,31 @@ def create_file_structure_function(get_files_list):
delete_file_structure(get_files_list)


@pytest.fixture(scope='function')
def file_monitoring(request):
"""Fixture to handle the monitoring of a specified file.

It uses de variable `file_to_monitor` to determinate the file to monitor. Default `LOG_FILE_PATH`

Args:
request (fixture): Provide information on the executing test function.
"""
if hasattr(request.module, 'file_to_monitor'):
file_to_monitor = getattr(request.module, 'file_to_monitor')
else:
file_to_monitor = LOG_FILE_PATH

logger.debug(f"Initializing file to monitor to {file_to_monitor}")

file_monitor = FileMonitor(file_to_monitor)
setattr(request.module, 'log_monitor', file_monitor)

yield

truncate_file(file_to_monitor)
logger.debug(f"Trucanted {file_to_monitor}")


@pytest.fixture(scope='module')
def configure_local_internal_options_module(request):
"""Fixture to configure the local internal options file.
Expand Down