Skip to content

Commit 660c269

Browse files
committed
test: add compatibility test for nested profiling in AdvancedProfiler (Python 3.12+)
1 parent 707f1c0 commit 660c269

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/tests_pytorch/profilers/test_profiler.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,12 @@ def test_advanced_profiler_deepcopy(advanced_profiler):
336336
assert deepcopy(advanced_profiler)
337337

338338

339+
def test_advanced_profiler_nested(advanced_profiler):
340+
"""Ensure AdvancedProfiler does not raise ValueError for nested profiling actions (Python 3.12+ compatibility)."""
341+
with advanced_profiler.profile("outer"), advanced_profiler.profile("inner"):
342+
pass # Should not raise ValueError
343+
344+
339345
@pytest.fixture
340346
def pytorch_profiler(tmp_path):
341347
return PyTorchProfiler(dirpath=tmp_path, filename="profiler")

0 commit comments

Comments
 (0)