mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Prevent users from seeing hardcoded print stmt when hypothesis is not installed (#142398)
Fixes: #142357 Pull Request resolved: https://github.com/pytorch/pytorch/pull/142398 Approved by: https://github.com/zou3519
This commit is contained in:
committed by
PyTorch MergeBot
parent
969b07b96f
commit
487343346e
@ -91,14 +91,8 @@ def is_forbidden_context_manager(ctx):
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
try:
|
||||
from torch.testing._internal.jit_utils import (
|
||||
_AssertRaisesRegexWithHighlightContext,
|
||||
)
|
||||
|
||||
f_ctxs.append(_AssertRaisesRegexWithHighlightContext)
|
||||
except ImportError:
|
||||
pass
|
||||
if m := sys.modules.get("torch.testing._internal.jit_utils"):
|
||||
f_ctxs.append(m._AssertRaisesRegexWithHighlightContext)
|
||||
|
||||
return ctx in f_ctxs
|
||||
|
||||
|
||||
@ -2570,7 +2570,7 @@ try:
|
||||
"pytorch_ci" if IS_CI else os.getenv('PYTORCH_HYPOTHESIS_PROFILE', 'dev')
|
||||
)
|
||||
except ImportError:
|
||||
print('Fail to import hypothesis in common_utils, tests are not derandomized')
|
||||
warnings.warn('Fail to import hypothesis in common_utils, tests are not derandomized', ImportWarning)
|
||||
|
||||
# Used in check_if_enable to see if a test method should be disabled by an issue,
|
||||
# sanitizes a test method name from appended suffixes by @dtypes parametrization.
|
||||
|
||||
Reference in New Issue
Block a user