From 2bd18b1b03e3131d0ccc14a0f14c370ab4f19731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Mon, 28 Nov 2016 09:28:46 +0100 Subject: [PATCH] image-build: Reduce duplication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All tests should print complete diffs on failure, so there is no need to define this in each test separately. Signed-off-by: Lubomír Sedlář --- tests/test_imagebuildphase.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tests/test_imagebuildphase.py b/tests/test_imagebuildphase.py index d1d07036..00cba88b 100644 --- a/tests/test_imagebuildphase.py +++ b/tests/test_imagebuildphase.py @@ -20,6 +20,10 @@ from tests.helpers import DummyCompose, PungiTestCase, boom class TestImageBuildPhase(PungiTestCase): + def setUp(self): + super(TestImageBuildPhase, self).setUp() + self.maxDiff = None + @mock.patch('pungi.phases.image_build.ThreadPool') def test_image_build(self, ThreadPool): compose = DummyCompose(self.topdir, { @@ -48,7 +52,6 @@ class TestImageBuildPhase(PungiTestCase): phase = ImageBuildPhase(compose) phase.run() - self.maxDiff = None # assert at least one thread was started self.assertTrue(phase.pool.add.called) @@ -102,7 +105,6 @@ class TestImageBuildPhase(PungiTestCase): "scratch": False, "failable_arches": ['x86_64'], } - self.maxDiff = None self.assertItemsEqual(phase.pool.queue_put.mock_calls, [mock.call((compose, client_args)), mock.call((compose, server_args))]) @@ -135,7 +137,6 @@ class TestImageBuildPhase(PungiTestCase): phase = ImageBuildPhase(compose) phase.run() - self.maxDiff = None # assert at least one thread was started self.assertTrue(phase.pool.add.called) @@ -165,7 +166,6 @@ class TestImageBuildPhase(PungiTestCase): "scratch": False, "failable_arches": [], } - self.maxDiff = None self.assertItemsEqual(phase.pool.queue_put.mock_calls, [mock.call((compose, server_args))]) @@ -194,7 +194,6 @@ class TestImageBuildPhase(PungiTestCase): phase = ImageBuildPhase(compose) phase.run() - self.maxDiff = None # assert at least one thread was started self.assertTrue(phase.pool.add.called) @@ -224,7 +223,6 @@ class TestImageBuildPhase(PungiTestCase): "scratch": False, "failable_arches": [], } - self.maxDiff = None self.assertItemsEqual(phase.pool.queue_put.mock_calls, [mock.call((compose, server_args))]) @@ -298,7 +296,6 @@ class TestImageBuildPhase(PungiTestCase): self.assertTrue(phase.pool.queue_put.called_once) args, kwargs = phase.pool.queue_put.call_args self.assertEqual(args[0][0], compose) - self.maxDiff = None self.assertDictEqual(args[0][1], { "format": [('docker', 'tar.xz')], "image_conf": { @@ -362,7 +359,6 @@ class TestImageBuildPhase(PungiTestCase): self.assertTrue(phase.pool.queue_put.called_once) args, kwargs = phase.pool.queue_put.call_args self.assertEqual(args[0][0], compose) - self.maxDiff = None self.assertDictEqual(args[0][1], { "format": [('docker', 'tar.xz')], "image_conf": { @@ -427,7 +423,6 @@ class TestImageBuildPhase(PungiTestCase): self.assertTrue(phase.pool.queue_put.called_once) args, kwargs = phase.pool.queue_put.call_args self.assertEqual(args[0][0], compose) - self.maxDiff = None self.assertDictEqual(args[0][1], { "format": [('docker', 'tar.xz')], "image_conf": {