diff --git a/FileArbDevOpsPython/Python.py b/FileArbDevOpsPython/Python.py index 638ad78..ffca73a 100644 --- a/FileArbDevOpsPython/Python.py +++ b/FileArbDevOpsPython/Python.py @@ -1,4 +1,5 @@ import glob +import multiprocessing import os import platform import sys @@ -7,7 +8,8 @@ PylintCommand = 'pylint --rcfile=.pylintrc --score=n ' def run_flake8() -> None: - flake8Command = 'flake8 -j 61 --config=.flake8 --show-source --benchmark' + cpuCount = multiprocessing.cpu_count() + flake8Command = f'flake8 -j {cpuCount} --config=.flake8 --show-source --benchmark' Process.fail_fast_run(flake8Command) def run_mypy() -> None: diff --git a/FileArbDevOpsPythonTests/FileArbDevOpsPythonTests.pyproj b/FileArbDevOpsPythonTests/FileArbDevOpsPythonTests.pyproj index bb94125..6ccf051 100644 --- a/FileArbDevOpsPythonTests/FileArbDevOpsPythonTests.pyproj +++ b/FileArbDevOpsPythonTests/FileArbDevOpsPythonTests.pyproj @@ -6,7 +6,7 @@ 5be2bd06-b3d6-4e12-9d37-cb82aa0ef9d3 - RunAll.py + PythonTests.py ..\ .. . diff --git a/FileArbDevOpsPythonTests/PythonTests.py b/FileArbDevOpsPythonTests/PythonTests.py index 2ad7219..bdd1aa5 100644 --- a/FileArbDevOpsPythonTests/PythonTests.py +++ b/FileArbDevOpsPythonTests/PythonTests.py @@ -1,5 +1,5 @@ - import glob +import multiprocessing import os import platform import sys @@ -22,11 +22,14 @@ class PythonTests(unittest.TestCase): @staticmethod @patch('FileArbDevOpsPython.Process.fail_fast_run', spec_set=True) - def test_run_flake8_RunsFlake8WithFlake8Config(_1): + @patch('multiprocessing.cpu_count', spec_set=True) + def test_run_flake8_RunsFlake8WithFlake8Config(_1, _2): + cpuCount = Random.integer() + multiprocessing.cpu_count.return_value = cpuCount # Python.run_flake8() # - expectedFlake8Command = 'flake8 -j 61 --config=.flake8 --show-source --benchmark' + expectedFlake8Command = f'flake8 -j {cpuCount} --config=.flake8 --show-source --benchmark' Process.fail_fast_run.assert_called_once_with(expectedFlake8Command) @staticmethod