Skip to content

Commit 7450d4b

Browse files
author
U. Artie Eoff
authored
WA: conftest do not overshadow tests/transformers/tests (#1813)
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
1 parent cd68dd6 commit 7450d4b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

conftest.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import json
22
import logging
33
import os
4+
import sys
45
from pathlib import Path
56

67
import pytest
78

8-
import tests.utils as oh_testutils
9-
109

1110
BASELINE_DIRECTORY = Path(__file__).parent.resolve() / Path("tests") / Path("baselines") / Path("fixture")
1211

@@ -123,11 +122,19 @@ def pytest_sessionstart(session):
123122
# use "gaudi1" since this is used in tests, baselines, etc.
124123
device = "gaudi1"
125124

126-
oh_testutils.OH_DEVICE_CONTEXT = device
125+
from tests import utils
126+
127+
utils.OH_DEVICE_CONTEXT = device
128+
session.config.stash["device-context"] = device
129+
130+
# WA: delete the imported top-level tests module so we don't overshadow
131+
# tests/transformers/tests module.
132+
# This fixes python -m pytest tests/transformers/tests/models/ -s -v
133+
del sys.modules["tests"]
127134

128135

129-
def pytest_report_header():
130-
return [f"device context: {oh_testutils.OH_DEVICE_CONTEXT}"]
136+
def pytest_report_header(config):
137+
return [f"device context: {config.stash['device-context']}"]
131138

132139

133140
def pytest_sessionfinish(session):

0 commit comments

Comments
 (0)