From 99e72ead68cb1816bcee860dbdfc747c17411648 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Feb 19 2019 22:29:25 +0000 Subject: Fix unit tests --- diff --git a/Makefile b/Makefile index 155ec9d..ffd1b88 100644 --- a/Makefile +++ b/Makefile @@ -80,10 +80,9 @@ test3: coverage3 erase PYTHONPATH=hub/.:plugins/hub/.:plugins/builder/.:plugins/cli/.:cli/. coverage3 run \ --rcfile .coveragerc3 --source . \ - /usr/bin/nosetests-3 \ - tests/test_lib tests/test_cli tests/test_hub - coverage report --rcfile .coveragerc3 - coverage html --rcfile .coveragerc3 + /usr/bin/nosetests-3 + coverage3 report --rcfile .coveragerc3 + coverage3 html --rcfile .coveragerc3 @echo Full coverage report at file://${PWD}/htmlcov/index.html test-tarball: diff --git a/koji/tasks.py b/koji/tasks.py index ba4cd31..999c37c 100644 --- a/koji/tasks.py +++ b/koji/tasks.py @@ -479,7 +479,7 @@ class BaseTaskHandler(object): fsrc = six.moves.urllib.request.urlopen(url) if not os.path.exists(os.path.dirname(fn)): os.makedirs(os.path.dirname(fn)) - with open(fn, 'wb') as fdst: + with open(fn, 'w') as fdst: shutil.copyfileobj(fsrc, fdst) fsrc.close() else: diff --git a/tests/test_builder/loadkojid.py b/tests/test_builder/loadkojid.py index d4e26e5..298ed91 100644 --- a/tests/test_builder/loadkojid.py +++ b/tests/test_builder/loadkojid.py @@ -6,7 +6,9 @@ import sys KOJID_FILENAME = os.path.dirname(__file__) + "/../../builder/kojid" if sys.version_info[0] >= 3: import importlib.util - spec = importlib.util.spec_from_file_location("koji_kojid", KOJID_FILENAME) + import importlib.machinery + loader = importlib.machinery.SourceFileLoader('koji_kojid', KOJID_FILENAME) + spec = importlib.util.spec_from_file_location("koji_kojid", loader=loader) kojid = importlib.util.module_from_spec(spec) spec.loader.exec_module(kojid) else: diff --git a/tests/test_builder/test_build_notification.py b/tests/test_builder/test_build_notification.py index 7bff6c1..5dae10e 100644 --- a/tests/test_builder/test_build_notification.py +++ b/tests/test_builder/test_build_notification.py @@ -2,7 +2,6 @@ from __future__ import absolute_import import json import mock import os -import smtplib import tempfile try: import unittest2 as unittest @@ -25,7 +24,7 @@ class MyClientSession(koji.ClientSession): fn = os.path.join(os.path.dirname(__file__), 'data/calls', name,'calls.json') with open(fn) as fp: data = json.load(fp) - data = koji.fixEncodingRecurse(data) + #data = koji.fixEncodingRecurse(data) for call in data: key = self._munge([call['method'], call['args'], call['kwargs']]) self._testcalls[key] = call @@ -101,6 +100,6 @@ class TestBuildNotification(unittest.TestCase): self.assertEqual(from_addr, "koji@example.com") self.assertEqual(recipients, ["user@example.com"]) fn = os.path.join(os.path.dirname(__file__), 'data/calls', 'build_notif_1', 'message.txt') - with open(fn) as fp: + with open(fn, 'rb') as fp: msg_expect = fp.read() self.assertEqual(message, msg_expect) diff --git a/tests/test_builder/test_volume_id.py b/tests/test_builder/test_volume_id.py index 0aff870..c37f622 100644 --- a/tests/test_builder/test_volume_id.py +++ b/tests/test_builder/test_volume_id.py @@ -84,7 +84,7 @@ class TestVolumeID(unittest.TestCase): def test_volume_id_substitutions(self): """Check that volume ID is shorten corect by shortenVolID method.""" - for test_name, values in self.test_cases.iteritems(): + for test_name, values in self.test_cases.items(): name = values['name'] expected_vol_id = values['expected-id'] result_vol_id = self.handler._shortenVolID(name, self.version, self.release)