You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "potiuk (via GitHub)" <gi...@apache.org> on 2023/09/03 11:17:38 UTC

[GitHub] [airflow] potiuk commented on a diff in pull request #34037: Fix issue with unit tests in subprocesses on macOS

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


##########
airflow/config_templates/unit_tests.cfg:
##########
@@ -59,6 +59,8 @@ unit_test_mode = True
 killed_task_cleanup_time = 5
 # We only allow our own classes to be deserialized in tests
 allowed_deserialization_classes = airflow\..* tests\..*
+# mocks from unittest.mock work correctly in subprocesses only if they are created by "fork" method
+mp_start_method = fork

Review Comment:
   > What is the difference between adding to unit_tests.cfg and conftest.py?
   
   To add what @Taragolis wrote - this has also changed recently - it used to be independently set but as of last month or so I changed it in the way that `AIRFLOW__CORE__UNIT_TEST_MODE` is actually set in `conftest.py` - so basically all Airflow unit tests always have the `AIRFLOW__CORE__UNIT_TEST_MODE` set to True. This was all part of restructuring the configuration.
   
   Right now - no matter how you run your tests they will have it set to True.
   
   So that configuration can be contributed by providers. So it could be set in either of the two places. 
   
   However, I think it's better to set this variable in conftest.py and only for MacOS because you can set it conditionally only when MacOS is detected. That's the nice thing about `conftest.py` that you can set variables and test configuraiton dynamically - by writing the imperative code rather than declare the configuration.
   
   This might have the nice thing that eventually somoene could run the full test suite on MacOS as well and fix all the issues that introduces (also conditionally) - while CI would continue to run the default "fork" mode in CI.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org