File tree Expand file tree Collapse file tree 1 file changed +17
-12
lines changed
Expand file tree Collapse file tree 1 file changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -1900,18 +1900,23 @@ def test_valid_output_formats(self):
19001900 """Test that all valid output formats are accepted."""
19011901 valid_formats = ["pstats" , "collapsed" , "flamegraph" ]
19021902
1903- for fmt in valid_formats :
1904- try :
1905- # This will likely fail with permissions, but the format should be valid
1906- profiling .sampling .sample .sample (
1907- os .getpid (),
1908- duration_sec = 0.1 ,
1909- output_format = fmt ,
1910- filename = f"test_{ fmt } .out" ,
1911- )
1912- except (OSError , RuntimeError , PermissionError ):
1913- # Expected errors - we just want to test format validation
1914- pass
1903+ tempdir = tempfile .TemporaryDirectory (delete = False )
1904+ self .addCleanup (lambda x : shutil .rmtree (x ), tempdir .name )
1905+
1906+
1907+ with contextlib .chdir (tempdir .name ):
1908+ for fmt in valid_formats :
1909+ try :
1910+ # This will likely fail with permissions, but the format should be valid
1911+ profiling .sampling .sample .sample (
1912+ os .getpid (),
1913+ duration_sec = 0.1 ,
1914+ output_format = fmt ,
1915+ filename = f"test_{ fmt } .out" ,
1916+ )
1917+ except (OSError , RuntimeError , PermissionError ):
1918+ # Expected errors - we just want to test format validation
1919+ pass
19151920
19161921
19171922class TestSampleProfilerCLI (unittest .TestCase ):
You can’t perform that action at this time.
0 commit comments