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 @@ -1825,18 +1825,23 @@ def test_valid_output_formats(self):
18251825 """Test that all valid output formats are accepted."""
18261826 valid_formats = ["pstats" , "collapsed" , "flamegraph" ]
18271827
1828- for fmt in valid_formats :
1829- try :
1830- # This will likely fail with permissions, but the format should be valid
1831- profiling .sampling .sample .sample (
1832- os .getpid (),
1833- duration_sec = 0.1 ,
1834- output_format = fmt ,
1835- filename = f"test_{ fmt } .out" ,
1836- )
1837- except (OSError , RuntimeError , PermissionError ):
1838- # Expected errors - we just want to test format validation
1839- pass
1828+ tempdir = tempfile .TemporaryDirectory (delete = False )
1829+ self .addCleanup (lambda x : shutil .rmtree (x ), tempdir .name )
1830+
1831+
1832+ with contextlib .chdir (tempdir .name ):
1833+ for fmt in valid_formats :
1834+ try :
1835+ # This will likely fail with permissions, but the format should be valid
1836+ profiling .sampling .sample .sample (
1837+ os .getpid (),
1838+ duration_sec = 0.1 ,
1839+ output_format = fmt ,
1840+ filename = f"test_{ fmt } .out" ,
1841+ )
1842+ except (OSError , RuntimeError , PermissionError ):
1843+ # Expected errors - we just want to test format validation
1844+ pass
18401845
18411846
18421847class TestSampleProfilerCLI (unittest .TestCase ):
You can’t perform that action at this time.
0 commit comments