Skip to content

Commit 4805bf6

Browse files
shijiashuaiqwencoder
andcommitted
fix(tests): properly import conftest helpers
Use try/except pattern to import conftest functions to support both pytest auto-import and direct module imports. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
1 parent 60b7ee0 commit 4805bf6

4 files changed

Lines changed: 19 additions & 7 deletions

File tree

tests/test_attention.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
except ImportError: # pragma: no cover - environment-dependent guard
1313
pytest.skip("PyTorch is not installed", allow_module_level=True)
1414

15-
# Import from conftest (pytest automatically makes conftest functions available)
16-
from conftest import assert_close, compute_attention_reference
15+
# Import helper functions from conftest
16+
try:
17+
from conftest import assert_close, compute_attention_reference
18+
except ImportError:
19+
# Fallback for direct module imports
20+
from tests.conftest import assert_close, compute_attention_reference
1721

1822
# Strategies for property-based testing
1923
batch_strategy = st.integers(min_value=1, max_value=4)

tests/test_gemm.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
except ImportError: # pragma: no cover - environment-dependent guard
1313
pytest.skip("PyTorch is not installed", allow_module_level=True)
1414

15-
# Import from conftest (pytest automatically makes conftest functions available)
16-
from conftest import assert_close
15+
# Import helper functions from conftest
16+
try:
17+
from conftest import assert_close
18+
except ImportError:
19+
# Fallback for direct module imports
20+
from tests.conftest import assert_close
1721

1822
# Strategies for property-based testing
1923
dim_strategy = st.integers(min_value=16, max_value=512)

tests/test_interface.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
except ImportError: # pragma: no cover - environment-dependent guard
1313
pytest.skip("PyTorch is not installed", allow_module_level=True)
1414

15-
# Import from conftest (pytest automatically makes conftest functions available)
16-
from conftest import assert_close
15+
# Import helper functions from conftest
16+
try:
17+
from conftest import assert_close
18+
except ImportError:
19+
# Fallback for direct module imports
20+
from tests.conftest import assert_close
1721

1822

1923
class TestPythonInterface:

tests/test_profiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
except ImportError:
1111
pytest.skip("CUDA kernels not built", allow_module_level=True)
1212

13-
from python.profiler import (
13+
from cuda_llm_ops.profiler import (
1414
Bottleneck,
1515
CUDAProfiler,
1616
KernelMetrics,

0 commit comments

Comments
 (0)