From 2af0996fa1f5de8613749f345b7759302c19fe1d Mon Sep 17 00:00:00 2001 From: Javier Pena Date: Wed, 2 Oct 2019 10:02:41 +0200 Subject: [PATCH] Properly mock cpu_affinity on all unit tests Two unit tests (test_cont_run_args_validation_true and test_cont_run_args_validation_false) relied on the machine running the tests having 8 CPUs. This is not always the case, so let's mock it, just like we do on tests expecting 4 CPUs. Change-Id: I98d930d9c7a1a2d54863749d08b97fc9e8867a0e --- paunch/tests/test_builder_podman.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/paunch/tests/test_builder_podman.py b/paunch/tests/test_builder_podman.py index e25807a..5a4dca4 100644 --- a/paunch/tests/test_builder_podman.py +++ b/paunch/tests/test_builder_podman.py @@ -73,8 +73,10 @@ class TestPodmanBuilder(base.TestBaseBuilder): cmd ) + @mock.patch("psutil.Process.cpu_affinity", + return_value=[0, 1, 2, 3, 4, 5, 6, 7]) @mock.patch('paunch.runner.PodmanRunner', autospec=True) - def test_cont_run_args_validation_true(self, runner): + def test_cont_run_args_validation_true(self, runner, mock_cpu): config = { 'one': { 'image': 'foo', @@ -93,8 +95,10 @@ class TestPodmanBuilder(base.TestBaseBuilder): cmd ) + @mock.patch("psutil.Process.cpu_affinity", + return_value=[0, 1, 2, 3, 4, 5, 6, 7]) @mock.patch('paunch.runner.PodmanRunner', autospec=True) - def test_cont_run_args_validation_false(self, runner): + def test_cont_run_args_validation_false(self, runner, mock_cpu): config = { 'one': { 'image': 'foo',