Skip test_wrap_bad if run under pytest (#115070)

Pytest replaces sys.stdout/stderr by `TextIOWrapper` instances which do not support `fileno()`
Hence skip that test in this case

Fixes #115069

Pull Request resolved: https://github.com/pytorch/pytorch/pull/115070
Approved by: https://github.com/clee2000
This commit is contained in:
Alexander Grund
2024-02-15 00:10:05 +00:00
committed by PyTorch MergeBot
parent d833e2f236
commit 99cb807e25
3 changed files with 12 additions and 10 deletions

View File

@ -1867,6 +1867,16 @@ def skipIfTBB(message="This test makes TBB sad"):
return dec_fn
def skip_if_pytest(fn):
@wraps(fn)
def wrapped(*args, **kwargs):
if "PYTEST_CURRENT_TEST" in os.environ:
raise unittest.SkipTest("does not work under pytest")
return fn(*args, **kwargs)
return wrapped
def slowTest(fn):
@wraps(fn)
def wrapper(*args, **kwargs):