@@ -489,3 +489,30 @@ def tearDown(self):
489489 os .environ .update (self ._pre_env )
490490 self .mock_os_cpu .stop ()
491491 self .mock_version_info .stop ()
492+
493+
494+ @unittest .skipIf (sys .version_info .minor != 10 ,
495+ "Run the tests only for Python 3.10. In other platforms, "
496+ "as the default passed is None, the cpu_count determines the "
497+ "number of max_workers and we cannot mock the os.cpu_count() "
498+ "in the concurrent.futures.ThreadPoolExecutor" )
499+ class TestThreadPoolSettingsPython310 (TestThreadPoolSettingsPython39 ):
500+ def setUp (self ):
501+ super (TestThreadPoolSettingsPython310 , self ).setUp ()
502+
503+ self .mock_os_cpu = patch (
504+ 'os.cpu_count' , return_value = 2 )
505+ # 6 - based on 2 cores - min(32, (os.cpu_count() or 1) + 4) - 2 + 4
506+ self ._default_workers : Optional [int ] = 6
507+ self .mock_version_info = patch (
508+ 'azure_functions_worker.dispatcher.sys.version_info' ,
509+ SysVersionInfo (3 , 10 , 0 , 'final' , 0 ))
510+
511+ self .mock_os_cpu .start ()
512+ self .mock_version_info .start ()
513+
514+ def tearDown (self ):
515+ os .environ .clear ()
516+ os .environ .update (self ._pre_env )
517+ self .mock_os_cpu .stop ()
518+ self .mock_version_info .stop ()
0 commit comments