From 9f92edd91f73a5ce3febf8cb1cc8235a3647ae3a Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Tue, 24 Sep 2024 21:09:24 +0200 Subject: [PATCH] rpmbuild: unblock testsuite --- rpmbuild/tests/test_base.py | 2 +- rpmbuild/tests/test_mock.py | 2 +- rpmbuild/tests/test_pypi.py | 4 ++-- rpmbuild/tests/test_rubygems.py | 6 +++--- rpmbuild/tests/test_scm.py | 8 ++++---- rpmbuild/tests/test_spec.py | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/rpmbuild/tests/test_base.py b/rpmbuild/tests/test_base.py index 5ecbd1e60..fc098b3e7 100644 --- a/rpmbuild/tests/test_base.py +++ b/rpmbuild/tests/test_base.py @@ -18,7 +18,7 @@ def setUp(self): super(TestProvider, self).setUp() self.source_json = {} - @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open()) + @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open) @mock.patch('copr_rpmbuild.providers.base.os.mkdir') def test_create_rpmmacros(self, mock_mkdir, mock_open): task = { diff --git a/rpmbuild/tests/test_mock.py b/rpmbuild/tests/test_mock.py index 11c41f193..964ef637c 100644 --- a/rpmbuild/tests/test_mock.py +++ b/rpmbuild/tests/test_mock.py @@ -227,7 +227,7 @@ def test_produce_rpm(self, popen_mock, get_mock_uniqueext_mock, '--scrub', 'root-cache', '--quiet']) assert get_mock_uniqueext_mock.call_count == 1 - @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open()) + @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open) def test_touch_success_file(self, mock_open): builder = MockBuilder(self.task, self.sourcedir, self.resultdir, self.config) builder.touch_success_file() diff --git a/rpmbuild/tests/test_pypi.py b/rpmbuild/tests/test_pypi.py index 34443bfe9..8543e8017 100644 --- a/rpmbuild/tests/test_pypi.py +++ b/rpmbuild/tests/test_pypi.py @@ -19,7 +19,7 @@ def setUp(self): "python_versions": [2, 3]} self.resultdir = "/path/to/resultdir" - @mock.patch("{0}.open".format(builtins)) + @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open) @mock.patch('copr_rpmbuild.providers.base.os.mkdir') def test_init(self, mock_mkdir, mock_open): provider = PyPIProvider(self.source_json, self.config) @@ -29,7 +29,7 @@ def test_init(self, mock_mkdir, mock_open): self.assertEqual(provider.python_versions, [2, 3]) @mock.patch("copr_rpmbuild.providers.pypi.run_cmd") - @mock.patch("{0}.open".format(builtins)) + @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open) @mock.patch('copr_rpmbuild.providers.base.os.mkdir') def test_produce_srpm(self, mock_mkdir, mock_open, run_cmd): provider = PyPIProvider(self.source_json, self.config) diff --git a/rpmbuild/tests/test_rubygems.py b/rpmbuild/tests/test_rubygems.py index 495bd2ca6..303812b05 100644 --- a/rpmbuild/tests/test_rubygems.py +++ b/rpmbuild/tests/test_rubygems.py @@ -18,14 +18,14 @@ def setUp(self): super(TestRubyGemsProvider, self).setUp() self.source_json = {"gem_name": "A_123"} - @mock.patch("{0}.open".format(builtins)) + @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open) @mock.patch('copr_rpmbuild.providers.base.os.mkdir') def test_init(self, mock_mkdir, mock_open): provider = RubyGemsProvider(self.source_json, self.config) self.assertEqual(provider.gem_name, "A_123") @mock.patch("copr_rpmbuild.providers.rubygems.run_cmd") - @mock.patch("{0}.open".format(builtins)) + @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open) @mock.patch('copr_rpmbuild.providers.base.os.mkdir') def test_produce_srpm(self, mock_mkdir, mock_open, run_cmd): provider = RubyGemsProvider(self.source_json, self.config) @@ -35,7 +35,7 @@ def test_produce_srpm(self, mock_mkdir, mock_open, run_cmd): run_cmd.assert_called_with(assert_cmd) @mock.patch("copr_rpmbuild.providers.rubygems.run_cmd") - @mock.patch("{0}.open".format(builtins)) + @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open) @mock.patch('copr_rpmbuild.providers.base.os.mkdir') def test_empty_license(self, mock_mkdir, mock_open, run_cmd): stderr = ("error: line 8: Empty tag: License:" diff --git a/rpmbuild/tests/test_scm.py b/rpmbuild/tests/test_scm.py index 801d42202..003a91146 100644 --- a/rpmbuild/tests/test_scm.py +++ b/rpmbuild/tests/test_scm.py @@ -34,7 +34,7 @@ def setUp(self): "srpm_build_method": "rpkg", } - @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open()) + @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open) @mock.patch('copr_rpmbuild.providers.base.os.mkdir') def test_init(self, mock_mkdir, mock_open): source_json = self.source_json.copy() @@ -90,7 +90,7 @@ def test_generate_rpkg_config(self): shutil.rmtree(tmpdir) - @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open()) + @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open) @mock.patch('copr_rpmbuild.providers.base.os.mkdir') def test_get_rpkg_command(self, mock_mkdir, mock_open): provider = ScmProvider(self.source_json, self.config) @@ -100,7 +100,7 @@ def test_get_rpkg_command(self, mock_mkdir, mock_open): "--spec", provider.spec_path] self.assertEqual(provider.get_rpkg_command(), assert_cmd) - @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open()) + @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open) @mock.patch('copr_rpmbuild.providers.base.os.mkdir') def test_get_tito_command(self, mock_mkdir, mock_open): provider = ScmProvider(self.source_json, self.config) @@ -110,7 +110,7 @@ def test_get_tito_command(self, mock_mkdir, mock_open): @mock.patch("copr_rpmbuild.helpers.run_cmd") - @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open()) + @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open) @mock.patch('copr_rpmbuild.providers.base.os.mkdir') def test_get_tito_test_command(self, mock_mkdir, mock_open, run_cmd_mock): provider = ScmProvider(self.source_json, self.config) diff --git a/rpmbuild/tests/test_spec.py b/rpmbuild/tests/test_spec.py index 62d64cbec..5f38ccee3 100644 --- a/rpmbuild/tests/test_spec.py +++ b/rpmbuild/tests/test_spec.py @@ -24,7 +24,7 @@ class TestUrlProvider(TestCase): def auto_test_setup(self): self.source_json = {"url": u"http://foo.ex/somepackage.spec"} - @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open()) + @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open) @mock.patch('copr_rpmbuild.providers.base.os.mkdir') def test_init(self, mock_mkdir, mock_open): provider = UrlProvider(self.source_json, self.config) @@ -32,7 +32,7 @@ def test_init(self, mock_mkdir, mock_open): @mock.patch('copr_common.request.SafeRequest.get') @mock.patch("copr_rpmbuild.providers.base.run_cmd") - @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open()) + @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open) @mock.patch("copr_rpmbuild.providers.spec.UrlProvider.create_rpmmacros") @mock.patch("copr_rpmbuild.providers.spec.UrlProvider.generate_mock_config") @mock.patch('copr_rpmbuild.providers.base.os.mkdir') @@ -52,7 +52,7 @@ def test_produce_srpm(self, mock_mkdir, mock_generate_mock_config, run_cmd.assert_called_with(args, cwd=provider.workdir) @mock.patch('copr_common.request.SafeRequest.get') - @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open()) + @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open) @mock.patch('copr_rpmbuild.providers.base.os.mkdir') def test_save_spec(self, mock_mkdir, mock_open, mock_get): provider = UrlProvider(self.source_json, self.config)