potiuk commented on code in PR #46891:
URL: https://github.com/apache/airflow/pull/46891#discussion_r2211852077


##########
airflow-core/tests/unit/cli/commands/test_api_server_command.py:
##########
@@ -296,16 +297,31 @@ def test_run_command_daemon(
                 )
             ]
             
mock_pid_file.assert_has_calls([mock.call(mock_setup_locations.return_value[0], 
-1)])
-            assert mock_open.mock_calls == [
-                mock.call(mock_setup_locations.return_value[1], "a"),
-                mock.call().__enter__(),
-                mock.call(mock_setup_locations.return_value[2], "a"),
-                mock.call().__enter__(),
-                mock.call().truncate(0),
-                mock.call().truncate(0),
-                mock.call().__exit__(None, None, None),
-                mock.call().__exit__(None, None, None),
-            ]
+            if sys.version_info >= (3, 13):
+                # extra close is called in Python 3.13+ to close the file 
descriptors
+                assert mock_open.mock_calls == [
+                    mock.call(mock_setup_locations.return_value[1], "a"),
+                    mock.call().__enter__(),
+                    mock.call(mock_setup_locations.return_value[2], "a"),
+                    mock.call().__enter__(),
+                    mock.call().truncate(0),
+                    mock.call().truncate(0),
+                    mock.call().__exit__(None, None, None),
+                    mock.call().close(),
+                    mock.call().__exit__(None, None, None),
+                    mock.call().close(),
+                ]
+            else:
+                assert mock_open.mock_calls == [
+                    mock.call(mock_setup_locations.return_value[1], "a"),
+                    mock.call().__enter__(),
+                    mock.call(mock_setup_locations.return_value[2], "a"),
+                    mock.call().__enter__(),
+                    mock.call().truncate(0),
+                    mock.call().truncate(0),
+                    mock.call().__exit__(None, None, None),
+                    mock.call().__exit__(None, None, None),
+                ]

Review Comment:
   It could be because of an effect of some optimizations implemented in 
Py3.13. I believe what **could** happen is that that close came later before 
and now it is optimised in to be called a bit earlier.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to