mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Make test_cpp_extensions_aot handle lack of pytest more gracefully (#53740)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/53740 Signed-off-by: Edward Z. Yang <ezyang@fb.com> Test Plan: Imported from OSS Reviewed By: albanD Differential Revision: D26956603 Pulled By: ezyang fbshipit-source-id: 09ff60b29c4bd64044f4c9f0b7e17ffed33c30db
This commit is contained in:
parent
7b939d934e
commit
4ffafbac40
|
|
@ -8,14 +8,23 @@ import torch
|
||||||
import torch.backends.cudnn
|
import torch.backends.cudnn
|
||||||
import torch.utils.cpp_extension
|
import torch.utils.cpp_extension
|
||||||
|
|
||||||
import pytest
|
try:
|
||||||
|
import pytest
|
||||||
|
HAS_PYTEST = True
|
||||||
|
except ImportError as e:
|
||||||
|
HAS_PYTEST = False
|
||||||
|
|
||||||
# TODO: Rewrite these tests so that they can be collected via pytest without
|
# TODO: Rewrite these tests so that they can be collected via pytest without
|
||||||
# using run_test.py
|
# using run_test.py
|
||||||
try:
|
try:
|
||||||
cpp_extension = pytest.importorskip("torch_test_cpp_extension.cpp")
|
if HAS_PYTEST:
|
||||||
msnpu_extension = pytest.importorskip("torch_test_cpp_extension.msnpu")
|
cpp_extension = pytest.importorskip("torch_test_cpp_extension.cpp")
|
||||||
rng_extension = pytest.importorskip("torch_test_cpp_extension.rng")
|
msnpu_extension = pytest.importorskip("torch_test_cpp_extension.msnpu")
|
||||||
|
rng_extension = pytest.importorskip("torch_test_cpp_extension.rng")
|
||||||
|
else:
|
||||||
|
import torch_test_cpp_extension.cpp as cpp_extension
|
||||||
|
import torch_test_cpp_extension.msnpu as msnpu_extension
|
||||||
|
import torch_test_cpp_extension.rng as rng_extension
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
"test_cpp_extensions_aot.py cannot be invoked directly. Run "
|
"test_cpp_extensions_aot.py cannot be invoked directly. Run "
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user