Skip to content

Commit

Permalink
add py 310 threadpoolsetting tests (#996)
Browse files Browse the repository at this point in the history
* add py 310 threadpoolsetting tests


Co-authored-by: peterstone2017 <yunchuwang5@gmail.com>
  • Loading branch information
YunchuWang and peterstone2017 authored Apr 11, 2022
1 parent 2de202a commit e4ac00f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/unittests/test_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,3 +489,30 @@ def tearDown(self):
os.environ.update(self._pre_env)
self.mock_os_cpu.stop()
self.mock_version_info.stop()


@unittest.skipIf(sys.version_info.minor != 10,
"Run the tests only for Python 3.10. In other platforms, "
"as the default passed is None, the cpu_count determines the "
"number of max_workers and we cannot mock the os.cpu_count() "
"in the concurrent.futures.ThreadPoolExecutor")
class TestThreadPoolSettingsPython310(TestThreadPoolSettingsPython39):
def setUp(self):
super(TestThreadPoolSettingsPython310, self).setUp()

self.mock_os_cpu = patch(
'os.cpu_count', return_value=2)
# 6 - based on 2 cores - min(32, (os.cpu_count() or 1) + 4) - 2 + 4
self._default_workers: Optional[int] = 6
self.mock_version_info = patch(
'azure_functions_worker.dispatcher.sys.version_info',
SysVersionInfo(3, 10, 0, 'final', 0))

self.mock_os_cpu.start()
self.mock_version_info.start()

def tearDown(self):
os.environ.clear()
os.environ.update(self._pre_env)
self.mock_os_cpu.stop()
self.mock_version_info.stop()

0 comments on commit e4ac00f

Please sign in to comment.