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

Fix conftest for e2e #111

Merged
merged 3 commits into from
Nov 8, 2024
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
24 changes: 21 additions & 3 deletions tests/e2e/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import os
import uuid
from datetime import (
Expand All @@ -21,6 +22,23 @@
# around names and values of the metadata.


@fixture(scope="session", autouse=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it still valid?

Copy link
Contributor Author

@kgodlewski kgodlewski Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def cleanup_logging_handlers():
"""Remove all logging handlers after each test session, to avoid
messy errors from the `logging` module.

The errors happen because `Run` installs `Run.close` as an `atexit` handler.
The method logs some messages. The output is captured by pytest, which closes
its logging handler early, causing "ValueError: I/O operation on closed file."
"""

try:
yield
finally:
logger = logging.getLogger("neptune")
logger.handlers.clear()


@fixture(scope="module")
def project(request):
# Assume the project name and API token are set in the environment using the standard
Expand Down Expand Up @@ -114,10 +132,10 @@ def run(project, run_init_kwargs):
@fixture(scope="module")
def sync_run(project, run_init_kwargs):
"""Blocking run for logging data"""
return SyncRun(**run_init_kwargs)
return SyncRun(project=run_init_kwargs["project"], run_id=run_init_kwargs["run_id"], resume=True)


@fixture
def ro_run(run, project):
def ro_run(project, run, run_init_kwargs):
"""ReadOnlyRun pointing to the same run as the neptune_scale.Run"""
return ReadOnlyRun(read_only_project=project, custom_id=run._run_id)
return ReadOnlyRun(read_only_project=project, custom_id=run_init_kwargs["run_id"])
Loading