Skip to content

Commit

Permalink
rpmbuild: unblock testsuite
Browse files Browse the repository at this point in the history
  • Loading branch information
praiskup authored and nikromen committed Sep 25, 2024
1 parent 5d77d36 commit 8b0977a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion rpmbuild/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion rpmbuild/tests/test_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions rpmbuild/tests/test_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions rpmbuild/tests/test_rubygems.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:"
Expand Down
8 changes: 4 additions & 4 deletions rpmbuild/tests/test_scm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions rpmbuild/tests/test_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ 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)
self.assertEqual(provider.url, "http://foo.ex/somepackage.spec")

@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')
Expand All @@ -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)
Expand Down

0 comments on commit 8b0977a

Please sign in to comment.