From 4adfd55b91fdbde9705610ff15c380ef263a78c7 Mon Sep 17 00:00:00 2001 From: "U. Artie Eoff" Date: Mon, 3 Mar 2025 11:28:19 -0500 Subject: [PATCH] WA: conftest do not overshadow tests/transformers/tests Signed-off-by: U. Artie Eoff --- conftest.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/conftest.py b/conftest.py index 72ee59caae..23c6df78b5 100644 --- a/conftest.py +++ b/conftest.py @@ -1,12 +1,11 @@ import json import logging import os +import sys from pathlib import Path import pytest -import tests.utils as oh_testutils - BASELINE_DIRECTORY = Path(__file__).parent.resolve() / Path("tests") / Path("baselines") / Path("fixture") @@ -123,11 +122,19 @@ def pytest_sessionstart(session): # use "gaudi1" since this is used in tests, baselines, etc. device = "gaudi1" - oh_testutils.OH_DEVICE_CONTEXT = device + from tests import utils + + utils.OH_DEVICE_CONTEXT = device + session.config.stash["device-context"] = device + + # WA: delete the imported top-level tests module so we don't overshadow + # tests/transformers/tests module. + # This fixes python -m pytest tests/transformers/tests/models/ -s -v + del sys.modules["tests"] -def pytest_report_header(): - return [f"device context: {oh_testutils.OH_DEVICE_CONTEXT}"] +def pytest_report_header(config): + return [f"device context: {config.stash['device-context']}"] def pytest_sessionfinish(session):