Skip to content

Commit feede35

Browse files
committed
update
1 parent 115ee41 commit feede35

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

tests/tests_fabric/plugins/precision/test_fsdp.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
from tests_fabric.helpers.runif import RunIf
2323

2424

25+
# Pytest passes args/kwargs to the context manager used with `pytest.warns`.
26+
# `contextlib.nullcontext` doesn't accept them, so this no-op version does.
2527
@contextmanager
26-
def null_ctx_manager(*args, **kwargs):
28+
def null_ctx(*args, **kwargs):
2729
yield
2830

2931

@@ -40,7 +42,7 @@ def null_ctx_manager(*args, **kwargs):
4042
def test_fsdp_precision_config(precision, expected):
4143
plugin = FSDPPrecision(precision=precision)
4244

43-
warning_ctx = pytest.warns if precision in ("16-true", "bf16-true") else null_ctx_manager
45+
warning_ctx = pytest.warns if precision in ("16-true", "bf16-true") else null_ctx
4446

4547
with warning_ctx(UserWarning, match="enables mixed-precision execution"):
4648
config = plugin.mixed_precision_config

tests/tests_pytorch/plugins/precision/test_fsdp.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
from tests_pytorch.helpers.runif import RunIf
2323

2424

25+
# Pytest passes args/kwargs to the context manager used with `pytest.warns`.
26+
# `contextlib.nullcontext` doesn't accept them, so this no-op version does.
2527
@contextmanager
26-
def null_ctx_manager(*args, **kwargs):
28+
def null_ctx(*args, **kwargs):
2729
yield
2830

2931

@@ -40,7 +42,7 @@ def null_ctx_manager(*args, **kwargs):
4042
def test_fsdp_precision_config(precision, expected):
4143
plugin = FSDPPrecision(precision=precision)
4244

43-
warning_ctx = pytest.warns if precision in ("16-true", "bf16-true") else null_ctx_manager
45+
warning_ctx = pytest.warns if precision in ("16-true", "bf16-true") else null_ctx
4446

4547
with warning_ctx(UserWarning, match="enables mixed-precision execution"):
4648
config = plugin.mixed_precision_config

0 commit comments

Comments
 (0)