@@ -66,8 +66,8 @@ def test_multiprocessing_spawn():
6666 pass
6767
6868
69- def test_multiprocessing_warning_in_fork ():
70- """Test that a warning is issued when using fork method (if OpenMP is enabled) ."""
69+ def test_multiprocessing_warning_detection ():
70+ """Test that the warning detection function exists and works correctly ."""
7171 # Skip on Windows
7272 if sys .platform == 'win32' :
7373 pytest .skip ("Test only relevant on Unix-like systems" )
@@ -76,16 +76,11 @@ def test_multiprocessing_warning_in_fork():
7676 if not rawpy .flags or not rawpy .flags .get ('OPENMP' , False ):
7777 pytest .skip ("OpenMP not enabled, warning not expected" )
7878
79- # This test can't easily be done in the same process
80- # because the warning only triggers in child processes
81- # So we'll just verify the warning code exists
79+ # Verify the warning function exists
8280 from rawpy import _check_multiprocessing_fork
83-
84- # The function exists
8581 assert _check_multiprocessing_fork is not None
8682
8783 # When called in main process, should not warn
88- # (we're in MainProcess here)
8984 with warnings .catch_warnings (record = True ) as w :
9085 warnings .simplefilter ("always" )
9186 _check_multiprocessing_fork ()
@@ -94,29 +89,11 @@ def test_multiprocessing_warning_in_fork():
9489 assert len (fork_warnings ) == 0
9590
9691
97- def child_process_function_for_warning_test ():
98- """
99- This function is meant to be run in a forked child process
100- to test if the warning is properly issued.
101- """
102- import warnings
103- with warnings .catch_warnings (record = True ) as w :
104- warnings .simplefilter ("always" )
105- import rawpy
106- # Trigger the check
107- with rawpy .imread (rawTestPath ) as raw :
108- raw .postprocess (half_size = True )
109-
110- # Check if warning was issued
111- fork_warnings = [warning for warning in w if 'fork' in str (warning .message ).lower ()]
112- return len (fork_warnings ) > 0
113-
114-
11592if __name__ == '__main__' :
11693 print ("Testing multiprocessing with spawn method..." )
11794 test_multiprocessing_spawn ()
11895 print ("SUCCESS: No deadlocks with spawn method!" )
11996
12097 print ("\n Testing warning detection..." )
121- test_multiprocessing_warning_in_fork ()
98+ test_multiprocessing_warning_detection ()
12299 print ("SUCCESS: Warning system working correctly!" )
0 commit comments