Skip to content

Commit

Permalink
Prevent users from seeing hardcoded print stmt when hypothesis is not…
Browse files Browse the repository at this point in the history
… installed (pytorch#142398)

Fixes: pytorch#142357

Pull Request resolved: pytorch#142398
Approved by: https://github.com/zou3519
  • Loading branch information
guilhermeleobas authored and pytorchmergebot committed Dec 17, 2024
1 parent 969b07b commit 4873433
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions torch/_dynamo/variables/user_defined.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion torch/testing/_internal/common_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2570,7 +2570,7 @@ def settings(*args, **kwargs):
"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.
Expand Down

0 comments on commit 4873433

Please sign in to comment.