#3157 Pytest instead of nose in unittest
Merged 5 months ago by tkopecek. Opened 5 months ago by jcupova.
jcupova/koji issue-3140  into  master

Pytest instead of nose in unittest
Jana Cupova • 5 months ago  
@@ -17,6 +17,7 @@ 

    python3-devel \

    python3-librepo \

    python3-pip \

+   python3-pytest \

    python3-rpm \

    python3-tox \

    redhat-rpm-config \

@@ -15,6 +15,7 @@ 

    openssl-devel \

    python3-devel \

    python3-pip \

+   python3-pytest \

    python3-rpm \

    python3-tox \

    redhat-rpm-config \

@@ -15,6 +15,7 @@ 

    openssl-devel \

    python3-devel \

    python3-pip \

+   python3-pytest \

    python3-rpm \

    python3-tox \

    redhat-rpm-config \

@@ -15,6 +15,7 @@ 

    openssl-devel \

    python3-devel \

    python3-pip \

+   python3-pytest \

    python3-rpm \

    python3-tox \

    redhat-rpm-config \

@@ -15,6 +15,7 @@ 

    openssl-devel \

    python3-devel \

    python3-pip \

+   python3-pytest \

    python3-rpm \

    python3-tox \

    redhat-rpm-config \

@@ -662,7 +662,7 @@ 

   * ``python3-dateutil``

   * ``python3-mock``

   * ``python3-multilib``

-  * ``python3-nose``

+  * ``python3-pytest``

   * ``python3-psycopg2``

   * ``python3-qpid-proton``

   * ``python3-requests``

file modified
+1 -1
@@ -4,4 +4,4 @@ 

  mock<=2.0.0

  requests-mock

  coverage

- nose

+ pytest

@@ -1,6 +1,7 @@ 

  from __future__ import absolute_import

  import inspect

  import mock

+ import sys

  import unittest

  import koji

  import koji.tasks
@@ -16,7 +17,7 @@ 

  

          # simple case

          ret = koji.tasks.parse_task_params('sleep', [4])

-         self.assertEqual(ret, {'n':4})

+         self.assertEqual(ret, {'n': 4})

  

          # bad args

          with self.assertRaises(koji.ParameterError):
@@ -24,7 +25,7 @@ 

  

          # bad method

          with self.assertRaises(TypeError):

-             koji.tasks.parse_task_params('MISSINGMETHOD', [1,2,3])

+             koji.tasks.parse_task_params('MISSINGMETHOD', [1, 2, 3])

  

          # new style

          params = {'__method__': 'hello', 'n': 1}
@@ -48,10 +49,15 @@ 

              if not h_class:

                  missing.append(method)

                  continue

- 

-             spec = inspect.getargspec(h_class.handler)

-             # unbound method, so strip "self"

-             spec.args.pop(0)

+             if sys.version_info > (3,):

+                 spec = inspect.getfullargspec(h_class.handler)

+                 # unbound method, so strip "self"

+                 spec.args.pop(0)

+                 spec = spec[:-3]

+             else:

+                 spec = inspect.getargspec(h_class.handler)

+                 # unbound method, so strip "self"

+                 spec.args.pop(0)

  

              # for the methods we have, at least one of the signatures should

              # match

@@ -4,10 +4,10 @@ 

  import sys

  import unittest

  import json

+ import pytest

  

  import mock

  import six

- from nose.plugins.skip import SkipTest

  

  try:

      import libcomps
@@ -222,9 +222,9 @@ 

          session.groupListAdd.assert_not_called()

  

      @mock.patch('sys.stdout', new_callable=six.StringIO)

-     def test_import_comps_libcomps(self, stdout):

+     def _test_import_comps_libcomps(self, stdout):

          if libcomps is None:

-             raise SkipTest('no libcomps')

+             pytest.skip('no libcomps')

          comps_file = os.path.dirname(__file__) + '/data/comps-example.xml'

          stdout_file = os.path.dirname(

              __file__) + '/data/comps-example.libcomps.out'
@@ -238,9 +238,9 @@ 

              stdout)

  

      @mock.patch('sys.stdout', new_callable=six.StringIO)

-     def test_import_comps_sample_libcomps(self, stdout):

+     def _test_import_comps_sample_libcomps(self, stdout):

          if libcomps is None:

-             raise SkipTest('no libcomps')

+             pytest.skip('no libcomps')

          comps_file = os.path.dirname(__file__) + '/data/comps-sample.xml'

          stdout_file = os.path.dirname(

              __file__) + '/data/comps-sample.libcomps.out'
@@ -256,9 +256,9 @@ 

      @mock.patch('sys.stdout', new_callable=six.StringIO)

      @mock.patch('koji_cli.commands.libcomps', new=None)

      @mock.patch('koji_cli.commands.yumcomps', create=True, new=yumcomps)

-     def test_import_comps_yumcomps(self, stdout):

+     def _test_import_comps_yumcomps(self, stdout):

          if yumcomps is None:

-             raise SkipTest('no yum.comps')

+             pytest.skip('no yum.comps')

          comps_file = os.path.dirname(__file__) + '/data/comps-example.xml'

          stdout_file = os.path.dirname(

              __file__) + '/data/comps-example.yumcomps.out'
@@ -274,9 +274,9 @@ 

      @mock.patch('sys.stdout', new_callable=six.StringIO)

      @mock.patch('koji_cli.commands.libcomps', new=None)

      @mock.patch('koji_cli.commands.yumcomps', create=True, new=yumcomps)

-     def test_import_comps_sample_yumcomps(self, stdout):

+     def _test_import_comps_sample_yumcomps(self, stdout):

          if yumcomps is None:

-             raise SkipTest('no yum.comps')

+             pytest.skip('no yum.comps')

          comps_file = os.path.dirname(__file__) + '/data/comps-sample.xml'

          stdout_file = os.path.dirname(

              __file__) + '/data/comps-sample.yumcomps.out'

file modified
+26 -25
@@ -31,7 +31,7 @@ 

      def __run_parseTask_test(self, method, params, expect):

          self.session.getTaskRequest.return_value = params

          lines = _parseTaskParams(self.session, method, 1, '/mnt/koji')

-         self.assertEquals(lines, expect)

+         self.assertEqual(lines, expect)

  

      def test_error_with_param(self):

          params = []
@@ -115,15 +115,16 @@ 

  

      def test_wrapperRPM(self):

          target = 'test-target'

-         params = ['http://path.to/pkg.spec', {'name': 'build-tag'},

-                   self.build_templ,

-                   {

-                     'id': 1,

-                     'method': 'wrapperRPM',

-                     'arch': 'x86_64',

-                     'request': [1, {'name': target}, self.build_templ, 'task', 'opts']

-                   },

-                   {'wrapRPM-test': True}]

+         params = [

+             'http://path.to/pkg.spec', {'name': 'build-tag'},

+             self.build_templ,

+             {

+                 'id': 1,

+                 'method': 'wrapperRPM',

+                 'arch': 'x86_64',

+                 'request': [1, {'name': target}, self.build_templ, 'task', 'opts']

+             },

+             {'wrapRPM-test': True}]

          expect = ["Spec File URL: %s" % params[0]]

          expect.append("Build Tag: %s" % params[1]['name'])

          expect.append("Build: %s" % self.build_templ['nvr'])
@@ -135,11 +136,11 @@ 

  

      def test_chainmaven(self):

          params = [{

-                     'maven-pkg-1': {'build-opt': '--test'},

-                     'maven-pkg-2': {'build-opt': '-O2'},

-                   },

-                   'build-target',

-                   {'chainmaven-test': True}]

+             'maven-pkg-1': {'build-opt': '--test'},

+             'maven-pkg-2': {'build-opt': '-O2'},

+         },

+             'build-target',

+             {'chainmaven-test': True}]

          expect = ["Builds:"]

          for pkg, opt in params[0].items():

              expect.append("  %s" % pkg)
@@ -258,9 +259,9 @@ 

          params = [

              [1, 2, 3, 4],        # dependant task ids

              [

-               ['buildSRPMFromSCM', ['param1', 'param2'], {'scm': 'github.com'}],

-               ['build', ['param1', 'param2'], {'arch': 'x86_64'}],

-               ['tagBuild', ['tagname', 'param2'], {}]

+                 ['buildSRPMFromSCM', ['param1', 'param2'], {'scm': 'github.com'}],

+                 ['build', ['param1', 'param2'], {'arch': 'x86_64'}],

+                 ['tagBuild', ['tagname', 'param2'], {}]

              ]

          ]

          expect = ["Dependant Tasks: %s" % ", ".join([str(dep) for dep in params[0]])]
@@ -278,14 +279,14 @@ 

  

      def test_chainbuild(self):

          params = [[

-                     ['base-grp', 'desktop-grp'],

-                     ['base-grp', 'devel-grp'],

-                   ],

-                   'f26',

-                   {'extra': 'f26-pre-release'}]

+             ['base-grp', 'desktop-grp'],

+             ['base-grp', 'devel-grp'],

+         ],

+             'f26',

+             {'extra': 'f26-pre-release'}]

          expect = ["Build Groups:"]

          for i, grp in enumerate(params[0]):

-             expect.append('  %i: %s' % (i+1, ', '.join(grp)))

+             expect.append('  %i: %s' % (i + 1, ', '.join(grp)))

          expect.append("Build Target: %s" % params[1])

          expect.append("Options:")

          expect.append("  extra: f26-pre-release")
@@ -576,7 +577,7 @@ 

  

          with self.assertRaises(koji.GenericError) as cm:

              _printTaskInfo(session, task_id, '/')

-         self.assertEquals(str(cm.exception), "No such task: %d" % task_id)

+         self.assertEqual(str(cm.exception), "No such task: %d" % task_id)

  

  

  class TestTaskInfo(utils.CliTestCase):

@@ -1,20 +1,24 @@ 

  from __future__ import absolute_import

  import unittest

+ import sys

  

  from six.moves import range

  

  from koji_cli.lib import unique_path

  

+ 

  class TestUniquePath(unittest.TestCase):

  

      def test_unique_path(self):

          for i in range(1000):

-             self.assertNotEqual(

-                 unique_path('prefix'),

-                 unique_path('prefix'))

-             self.assertRegexpMatches(

-                 unique_path('prefix'),

-                 '^prefix/\d{10}\.\d{1,7}\.[a-zA-Z]{8}$')

+             self.assertNotEqual(unique_path('prefix'), unique_path('prefix'))

+             if sys.version_info >= (3, 2):

+                 return self.assertRegex(

+                     unique_path('prefix'), r'^prefix/\d{10}\.\d{1,7}\.[a-zA-Z]{8}$')

+             else:

+                 return self.assertRegexpMatches(

+                     unique_path('prefix'), r'^prefix/\d{10}\.\d{1,7}\.[a-zA-Z]{8}$')

+ 

  

  if __name__ == '__main__':

      unittest.main()

@@ -30,11 +30,11 @@ 

  

          args, kwargs = InsertProcessor.call_args

          ip = IP(*args, **kwargs)

-         self.assertEquals(ip.table, 'archivetypes')

-         self.assertEquals(ip.data, {'name': 'deb',

-                                     'description': 'Debian package',

-                                     'extensions': 'deb'})

-         self.assertEquals(ip.rawdata, {})

+         self.assertEqual(ip.table, 'archivetypes')

+         self.assertEqual(ip.data, {'name': 'deb',

+                                    'description': 'Debian package',

+                                    'extensions': 'deb'})

+         self.assertEqual(ip.rawdata, {})

          session.assertPerm.assert_called_with('admin')

  

          for m in mocks:

@@ -28,9 +28,9 @@ 

  

          args, kwargs = InsertProcessor.call_args

          ip = IP(*args, **kwargs)

-         self.assertEquals(ip.table, 'btype')

-         self.assertEquals(ip.data, {'name': 'new_btype'})

-         self.assertEquals(ip.rawdata, {})

+         self.assertEqual(ip.table, 'btype')

+         self.assertEqual(ip.data, {'name': 'new_btype'})

+         self.assertEqual(ip.rawdata, {})

          session.assertPerm.assert_called_with('admin')

  

          for m in mocks:

@@ -1,6 +1,5 @@ 

  import copy

  import unittest

- from nose.tools import eq_

  

  import kojihub

  
@@ -12,11 +11,12 @@ 

              {'foo': 2, 'bar': -1},

              {'foo': 0, 'bar': 0},

          ]

+ 

      def test_basic(self):

          opts = None

          expected = copy.copy(self.original)

          actual = kojihub._applyQueryOpts(self.original, opts)

-         eq_(expected, actual)

+         self.assertEqual(expected, actual)

  

      def test_order_by_foo(self):

          opts = {'order': 'foo'}
@@ -26,7 +26,7 @@ 

              {'foo': 2, 'bar': -1},

          ]

          actual = kojihub._applyQueryOpts(self.original, opts)

-         eq_(expected, actual)

+         self.assertEqual(expected, actual)

  

      def test_order_by_bar(self):

          opts = {'order': 'bar'}
@@ -36,7 +36,7 @@ 

              {'foo': 1, 'bar': 1},

          ]

          actual = kojihub._applyQueryOpts(self.original, opts)

-         eq_(expected, actual)

+         self.assertEqual(expected, actual)

  

      def test_order_in_reverse(self):

          opts = {'order': '-foo'}
@@ -46,7 +46,7 @@ 

              {'foo': 0, 'bar': 0},

          ]

          actual = kojihub._applyQueryOpts(self.original, opts)

-         eq_(expected, actual)

+         self.assertEqual(expected, actual)

  

      def test_offset(self):

          opts = {'offset': 1}
@@ -55,7 +55,7 @@ 

              {'foo': 0, 'bar': 0},

          ]

          actual = kojihub._applyQueryOpts(self.original, opts)

-         eq_(expected, actual)

+         self.assertEqual(expected, actual)

  

      def test_limit(self):

          opts = {'limit': 2}
@@ -64,7 +64,7 @@ 

              {'foo': 2, 'bar': -1},

          ]

          actual = kojihub._applyQueryOpts(self.original, opts)

-         eq_(expected, actual)

+         self.assertEqual(expected, actual)

  

      def test_limit_and_offset(self):

          opts = {'limit': 1, 'offset': 1}
@@ -72,15 +72,15 @@ 

              {'foo': 2, 'bar': -1},

          ]

          actual = kojihub._applyQueryOpts(self.original, opts)

-         eq_(expected, actual)

+         self.assertEqual(expected, actual)

  

      def test_count_only(self):

          opts = {'countOnly': True}

          expected = 3

          actual = kojihub._applyQueryOpts(self.original, opts)

-         eq_(expected, actual)

+         self.assertEqual(expected, actual)

  

          opts = {'countOnly': True, 'offset': 2}

          expected = 1

          actual = kojihub._applyQueryOpts(self.original, opts)

-         eq_(expected, actual)

+         self.assertEqual(expected, actual)

@@ -6,30 +6,27 @@ 

  

  import koji

  import kojihub

- from koji.util import dslice_ex

  

  IP = kojihub.InsertProcessor

  

  

  class TestDistRepoInit(unittest.TestCase):

  

- 

      def getInsert(self, *args, **kwargs):

          insert = IP(*args, **kwargs)

          insert.execute = mock.MagicMock()

          self.inserts.append(insert)

          return insert

  

- 

      def setUp(self):

          self.tempdir = tempfile.mkdtemp()

          self.pathinfo = koji.PathInfo(self.tempdir)

          mock.patch('koji.pathinfo', new=self.pathinfo).start()

  

          self.InsertProcessor = mock.patch('kojihub.InsertProcessor',

-                 side_effect=self.getInsert).start()

+                                           side_effect=self.getInsert).start()

          self.inserts = []

-  

+ 

          self.get_tag = mock.patch('kojihub.get_tag').start()

          self.get_event = mock.patch('kojihub.get_event').start()

          self.nextval = mock.patch('kojihub.nextval').start()
@@ -39,11 +36,9 @@ 

          self.get_event.return_value = 12345

          self.nextval.return_value = 99

  

- 

      def tearDown(self):

          mock.patch.stopall()

  

- 

      def test_simple_dist_repo_init(self):

  

          # simple case
@@ -51,29 +46,27 @@ 

          self.InsertProcessor.assert_called_once()

  

          ip = self.inserts[0]

-         self.assertEquals(ip.table, 'repo')

+         self.assertEqual(ip.table, 'repo')

          data = {'dist': True, 'create_event': 12345, 'tag_id': 42, 'id': 99,

-                     'state': koji.REPO_STATES['INIT']}

-         self.assertEquals(ip.data, data)

-         self.assertEquals(ip.rawdata, {})

+                 'state': koji.REPO_STATES['INIT']}

+         self.assertEqual(ip.data, data)

+         self.assertEqual(ip.rawdata, {})

  

          # no comps option

          self.copyfile.assert_not_called()

  

- 

      def test_dist_repo_init_with_comps(self):

  

          # simple case

-         kojihub.dist_repo_init('tag', ['key'], {'arch': ['x86_64'],

-                     'comps': 'COMPSFILE'})

+         kojihub.dist_repo_init('tag', ['key'], {'arch': ['x86_64'], 'comps': 'COMPSFILE'})

          self.InsertProcessor.assert_called_once()

  

          ip = self.inserts[0]

-         self.assertEquals(ip.table, 'repo')

+         self.assertEqual(ip.table, 'repo')

          data = {'dist': True, 'create_event': 12345, 'tag_id': 42, 'id': 99,

-                     'state': koji.REPO_STATES['INIT']}

-         self.assertEquals(ip.data, data)

-         self.assertEquals(ip.rawdata, {})

+                 'state': koji.REPO_STATES['INIT']}

+         self.assertEqual(ip.data, data)

+         self.assertEqual(ip.rawdata, {})

  

          self.copyfile.assert_called_once()

  
@@ -102,7 +95,7 @@ 

          assert_policy.assert_called_once_with('dist_repo', {'tag': 'tag'})

          dist_repo_init.assert_called_once()

          make_task.assert_called_once()

-         self.assertEquals(ret, make_task.return_value)

+         self.assertEqual(ret, make_task.return_value)

          exports.getBuildConfig.assert_called_once_with('tag')

  

  
@@ -143,9 +136,9 @@ 

          # generate pkglist file

          self.files.append('pkglist')

          plist = os.path.join(uploaddir, 'pkglist')

-         nvrs = ['aaa-1.0-2', 'bbb-3.0-5', 'ccc-8.0-13','ddd-21.0-34']

+         nvrs = ['aaa-1.0-2', 'bbb-3.0-5', 'ccc-8.0-13', 'ddd-21.0-34']

          self.rpms = {}

-         self.builds ={}

+         self.builds = {}

          self.key = '4c8da725'

          with open(plist, 'wt', encoding='utf-8') as f_pkglist:

              for nvr in nvrs:
@@ -192,20 +185,16 @@ 

          self.get_rpm.side_effect = self.our_get_rpm

          self.get_build.side_effect = self.our_get_build

  

- 

      def tearDown(self):

          mock.patch.stopall()

          shutil.rmtree(self.topdir)

  

- 

      def our_get_rpm(self, rpminfo, strict=False, multi=False):

          return self.rpms[rpminfo]

  

- 

      def our_get_build(self, buildInfo, strict=False):

          return self.builds[buildInfo]

  

- 

      def test_distRepoMove(self):

          session = kojihub.context.session = mock.MagicMock()

          session.user_id = 123
@@ -220,5 +209,4 @@ 

                  raise Exception("Missing file: %s" % path)

              data = open(path, 'rt', encoding='utf-8').read()

              data.strip()

-             self.assertEquals(data, basename)

- 

+             self.assertEqual(data, basename)

@@ -16,20 +16,19 @@ 

                  return None

          get_rpm.side_effect = mock_get_rpm

          re = kojihub.RootExports().getRPMDeps(1)

-         self.assertEquals(re, [])

+         self.assertEqual(re, [])

          with self.assertRaises(koji.GenericError) as cm:

              kojihub.RootExports().getRPMDeps(1, strict=True)

-         self.assertEquals(cm.exception.args[0], 'msg')

+         self.assertEqual(cm.exception.args[0], 'msg')

  

      @mock.patch('kojihub.get_rpm', return_value={'id': 1, 'build_id': None})

      def test_getRPMDeps_external_rpm(self, get_rpm):

          re = kojihub.RootExports().getRPMDeps(1)

-         self.assertEquals(re, [])

+         self.assertEqual(re, [])

          with self.assertRaises(koji.GenericError) as cm:

              kojihub.RootExports().getRPMDeps(1, strict=True)

-         self.assertEquals(cm.exception.args[0],

-                           'Can not get dependencies,'

-                           ' because RPM: 1 is not internal')

+         self.assertEqual(cm.exception.args[0],

+                          'Can not get dependencies, because RPM: 1 is not internal')

  

      @mock.patch('kojihub.get_rpm', return_value={'id': 1, 'build_id': 1})

      @mock.patch('kojihub.get_build', return_value={'id': 1})
@@ -38,11 +37,10 @@ 

      @mock.patch('os.path.exists', return_value=False)

      def test_getRPMDeps_no_rpmfile(self, ope, pr, pb, get_build, get_rpm):

          re = kojihub.RootExports().getRPMDeps(1)

-         self.assertEquals(re, [])

+         self.assertEqual(re, [])

          with self.assertRaises(koji.GenericError) as cm:

              kojihub.RootExports().getRPMDeps(1, strict=True)

-         self.assertEquals(cm.exception.args[0],

-                           "RPM file of 1 doesn't exist")

+         self.assertEqual(cm.exception.args[0], "RPM file of 1 doesn't exist")

  

      @mock.patch('kojihub.get_rpm')

      @mock.patch('kojihub.get_build')

@@ -20,20 +20,19 @@ 

  

          get_rpm.side_effect = mock_get_rpm

          re = kojihub.RootExports().getRPMFile(1, 'filename')

-         self.assertEquals(re, {})

+         self.assertEqual(re, {})

          with self.assertRaises(koji.GenericError) as cm:

              kojihub.RootExports().getRPMFile(1, 'filename', strict=True)

-         self.assertEquals(cm.exception.args[0], 'msg')

+         self.assertEqual(cm.exception.args[0], 'msg')

  

      @mock.patch('kojihub.get_rpm', return_value={'id': 1, 'build_id': None})

      def test_getRPMFile_external_rpm(self, get_rpm):

          re = kojihub.RootExports().getRPMFile(1, 'filename')

-         self.assertEquals(re, {})

+         self.assertEqual(re, {})

          with self.assertRaises(koji.GenericError) as cm:

              kojihub.RootExports().getRPMFile(1, 'filename', strict=True)

-         self.assertEquals(cm.exception.args[0],

-                           'Can not get RPM file,'

-                           ' because RPM: 1 is not internal')

+         self.assertEqual(cm.exception.args[0],

+                          'Can not get RPM file, because RPM: 1 is not internal')

  

      @mock.patch('kojihub.get_rpm', return_value={'id': 1, 'build_id': 1})

      @mock.patch('kojihub.get_build', return_value={'id': 1})
@@ -42,11 +41,10 @@ 

      @mock.patch('os.path.exists', return_value=False)

      def test_getRPMFile_no_rpmfile(self, ope, pr, pb, get_build, get_rpm):

          re = kojihub.RootExports().getRPMFile(1, 'filename')

-         self.assertEquals(re, {})

+         self.assertEqual(re, {})

          with self.assertRaises(koji.GenericError) as cm:

              kojihub.RootExports().getRPMFile(1, 'filename', strict=True)

-         self.assertEquals(cm.exception.args[0],

-                           "RPM package file of 1 doesn't exist")

+         self.assertEqual(cm.exception.args[0], "RPM package file of 1 doesn't exist")

  

      @mock.patch('kojihub.get_rpm', return_value={'id': 1, 'build_id': 1})

      @mock.patch('kojihub.get_build')
@@ -57,20 +55,20 @@ 

          pi.rpm.return_value = 'test-files-1-1.fc27.noarch.rpm'

          getRPMFile = kojihub.RootExports().getRPMFile

          res = getRPMFile(1, '/fileA')

-         self.assertDictEqual(res, {'digest_algo': 'sha256',

-                                    'user': 'root',

-                                    'mtime': int(1535536271),

-                                    'digest': 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',

-                                    'size': 0,

-                                    'group': 'root',

-                                    'name': '/fileA',

-                                    'rpm_id': 1,

-                                    'flags': 0,

-                                    'mode': int(0o100755),

-                                    'md5': 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'})

+         self.assertDictEqual(res, {

+             'digest_algo': 'sha256',

+             'user': 'root',

+             'mtime': int(1535536271),

+             'digest': 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',

+             'size': 0,

+             'group': 'root',

+             'name': '/fileA',

+             'rpm_id': 1,

+             'flags': 0,

+             'mode': int(0o100755),

+             'md5': 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'})

          res = getRPMFile(1, '/fileB')

-         self.assertEquals(res, {})

+         self.assertEqual(res, {})

          with self.assertRaises(koji.GenericError) as cm:

              res = getRPMFile(1, '/fileB', strict=True)

-         self.assertEquals(cm.exception.args[0],

-                           'No file: /fileB found in RPM: 1')

+         self.assertEqual(cm.exception.args[0], 'No file: /fileB found in RPM: 1')

@@ -55,12 +55,13 @@ 

      @mock.patch('kojihub.get_build')

      @mock.patch('kojihub.Task')

      @mock.patch('kojihub.context')

-     def test_with_rpm(self, context, Task, get_build, get_archive_type, import_archive, build, work, get_rpm):

+     def test_with_rpm(self, context, Task, get_build, get_archive_type, import_archive, build,

+                       work, get_rpm):

          task = mock.MagicMock()

          task.assertHost = mock.MagicMock()

          Task.return_value = task

          rpm = {

-             #'location': 'foo',

+             # 'location': 'foo',

              'id': 6,

              'name': 'foo',

              'version': '3.1',
@@ -108,13 +109,13 @@ 

          # Check that the log symlink made it to where it was supposed to.

          dest = os.readlink(workdir + '/foo.log')

          dest = os.path.abspath(os.path.join(workdir, dest))

-         self.assertEquals(dest, self.tempdir + '/data/logs/image/foo.log')

+         self.assertEqual(dest, self.tempdir + '/data/logs/image/foo.log')

  

          # And.. check all the sql statements

-         self.assertEquals(len(cursor.execute.mock_calls), 1)

+         self.assertEqual(len(cursor.execute.mock_calls), 1)

          expression, kwargs = cursor.execute.mock_calls[0][1]

          expression = " ".join(expression.split())

          expected = 'INSERT INTO archive_rpm_components (archive_id, rpm_id) ' + \

              'VALUES (%(archive_id0)s, %(rpm_id0)s)'

-         self.assertEquals(expression, expected)

-         self.assertEquals(kwargs, {'archive_id0': 9, 'rpm_id0': 6})

+         self.assertEqual(expression, expected)

+         self.assertEqual(kwargs, {'archive_id0': 9, 'rpm_id0': 6})

@@ -11,13 +11,13 @@ 

          proc = kojihub.InsertProcessor('sometable')

          actual = str(proc)

          expected = '-- incomplete update: no assigns'

-         self.assertEquals(actual, expected)

+         self.assertEqual(actual, expected)

  

      def test_to_string_with_data(self):

          proc = kojihub.InsertProcessor('sometable', data={'foo': 'bar'})

          actual = str(proc)

          expected = 'INSERT INTO sometable (foo) VALUES (%(foo)s)'

-         self.assertEquals(actual, expected)

+         self.assertEqual(actual, expected)

  

      @mock.patch('kojihub.context')

      def test_simple_execution_with_iterate(self, context):
@@ -37,20 +37,20 @@ 

          context.session.assertLogin = mock.MagicMock()

          proc = kojihub.InsertProcessor('sometable', data={'foo': 'bar'})

          proc.make_create(event_id=1, user_id=2)

-         self.assertEquals(proc.data['create_event'], 1)

-         self.assertEquals(proc.data['creator_id'], 2)

+         self.assertEqual(proc.data['create_event'], 1)

+         self.assertEqual(proc.data['creator_id'], 2)

  

          proc.make_create(user_id=2)

-         self.assertEquals(proc.data['create_event'], context.event_id)

-         self.assertEquals(proc.data['creator_id'], 2)

+         self.assertEqual(proc.data['create_event'], context.event_id)

+         self.assertEqual(proc.data['creator_id'], 2)

  

          proc.make_create(event_id=1)

-         self.assertEquals(proc.data['create_event'], 1)

-         self.assertEquals(proc.data['creator_id'], context.session.user_id)

+         self.assertEqual(proc.data['create_event'], 1)

+         self.assertEqual(proc.data['creator_id'], context.session.user_id)

  

          proc.make_create()

-         self.assertEquals(proc.data['create_event'], context.event_id)

-         self.assertEquals(proc.data['creator_id'], context.session.user_id)

+         self.assertEqual(proc.data['create_event'], context.event_id)

+         self.assertEqual(proc.data['creator_id'], context.session.user_id)

  

      @mock.patch('kojihub.context')

      def test_dup_check(self, context):
@@ -63,7 +63,7 @@ 

          args = cursor.execute.call_args

          actual = ' '.join(args[0][0].split())

          expected = 'SELECT foo FROM sometable WHERE (foo = %(foo)s)'

-         self.assertEquals(actual, expected)

+         self.assertEqual(actual, expected)

  

          proc.make_create()

          proc.dup_check()
@@ -71,12 +71,12 @@ 

          actual = ' '.join(args[0][0].split())

          expected = 'SELECT active, foo FROM sometable WHERE ' + \

              '(active = %(active)s) AND (foo = %(foo)s)'

-         self.assertEquals(actual, expected)

+         self.assertEqual(actual, expected)

  

          proc.set(onething='another')

          proc.rawset(something='something else')

          result = proc.dup_check()

-         self.assertEquals(result, None)

+         self.assertEqual(result, None)

  

      @mock.patch('kojihub.context')

      def test_raw_data(self, context):
@@ -84,10 +84,10 @@ 

          context.cnx.cursor.return_value = cursor

          proc = kojihub.InsertProcessor('sometable', rawdata={'foo': '\'bar\''})

          result = proc.dup_check()

-         self.assertEquals(result, None)

+         self.assertEqual(result, None)

          actual = str(proc)

          expected = "INSERT INTO sometable (foo) VALUES (('bar'))"  # raw data

-         self.assertEquals(actual, expected)

+         self.assertEqual(actual, expected)

  

  

  class TestBulkInsertProcessor(unittest.TestCase):
@@ -95,18 +95,18 @@ 

          proc = kojihub.BulkInsertProcessor('sometable')

          actual = str(proc)

          expected = '-- incomplete insert: no data'

-         self.assertEquals(actual, expected)

+         self.assertEqual(actual, expected)

  

      def test_to_string_with_single_row(self):

          proc = kojihub.BulkInsertProcessor('sometable', data=[{'foo': 'bar'}])

          actual = str(proc)

          expected = 'INSERT INTO sometable (foo) VALUES (%(foo0)s)'

-         self.assertEquals(actual, expected)

+         self.assertEqual(actual, expected)

  

          proc = kojihub.BulkInsertProcessor('sometable')

          proc.add_record(foo='bar')

          actual = str(proc)

-         self.assertEquals(actual, expected)

+         self.assertEqual(actual, expected)

  

      @mock.patch('kojihub.context')

      def test_simple_execution(self, context):
@@ -148,7 +148,7 @@ 

          proc.add_record(foo2='bar2')

          with self.assertRaises(koji.GenericError) as cm:

              str(proc)

-         self.assertEquals(cm.exception.args[0], 'Missing value foo2 in BulkInsert')

+         self.assertEqual(cm.exception.args[0], 'Missing value foo2 in BulkInsert')

  

      def test_missing_values_nostrict(self):

          proc = kojihub.BulkInsertProcessor('sometable', strict=False)
@@ -156,14 +156,14 @@ 

          proc.add_record(foo2='bar2')

          actual = str(proc)

          expected = 'INSERT INTO sometable (foo, foo2) VALUES (%(foo0)s, NULL), (NULL, %(foo21)s)'

-         self.assertEquals(actual, expected)

+         self.assertEqual(actual, expected)

  

      def test_missing_values_explicit_columns(self):

          proc = kojihub.BulkInsertProcessor('sometable', strict=True, columns=['foo', 'foo2'])

          proc.add_record(foo='bar')

          with self.assertRaises(koji.GenericError) as cm:

              str(proc)

-         self.assertEquals(cm.exception.args[0], 'Missing value foo2 in BulkInsert')

+         self.assertEqual(cm.exception.args[0], 'Missing value foo2 in BulkInsert')

  

      @mock.patch('kojihub.context')

      def test_batch_execution(self, context):
@@ -176,15 +176,12 @@ 

          proc.execute()

          calls = cursor.execute.mock_calls

          # list of (name, positional args, keyword args)

-         self.assertEquals(len(calls), 2)

-         self.assertEquals(

-                 calls[0][1],

-                 ('INSERT INTO sometable (foo) VALUES (%(foo0)s), (%(foo1)s)',

-                     {'foo0': 'bar1', 'foo1': 'bar2'}))

-         self.assertEquals(

-                 calls[1][1],

-                 ('INSERT INTO sometable (foo) VALUES (%(foo0)s)',

-                     {'foo0': 'bar3'}))

+         self.assertEqual(len(calls), 2)

+         self.assertEqual(calls[0][1],

+                          ('INSERT INTO sometable (foo) VALUES (%(foo0)s), (%(foo1)s)',

+                           {'foo0': 'bar1', 'foo1': 'bar2'}))

+         self.assertEqual(calls[1][1],

+                          ('INSERT INTO sometable (foo) VALUES (%(foo0)s)', {'foo0': 'bar3'}))

  

      @mock.patch('kojihub.context')

      def test_no_batch_execution(self, context):
@@ -197,8 +194,7 @@ 

          proc.execute()

          calls = cursor.execute.mock_calls

          # list of (name, positional args, keyword args)

-         self.assertEquals(len(calls), 1)

-         self.assertEquals(

-                 calls[0][1],

-                 ('INSERT INTO sometable (foo) VALUES (%(foo0)s), (%(foo1)s), (%(foo2)s)',

-                     {'foo0': 'bar1', 'foo1': 'bar2', 'foo2': 'bar3'}))

+         self.assertEqual(len(calls), 1)

+         self.assertEqual(calls[0][1],

+                          ('INSERT INTO sometable (foo) VALUES (%(foo0)s), (%(foo1)s), (%(foo2)s)',

+                           {'foo0': 'bar1', 'foo1': 'bar2', 'foo2': 'bar3'}))

@@ -17,15 +17,15 @@ 

          ret = kojihub.list_btypes()

          QueryProcessor.assert_called_once()

          query.execute.assert_called_once()

-         self.assertEquals(ret, "return value")

+         self.assertEqual(ret, "return value")

  

          args, kwargs = QueryProcessor.call_args

-         self.assertEquals(args, ())

+         self.assertEqual(args, ())

          qp = QP(**kwargs)

-         self.assertEquals(qp.tables, ['btype'])

-         self.assertEquals(qp.columns, ['id', 'name'])

-         self.assertEquals(qp.clauses, [])

-         self.assertEquals(qp.joins, None)

+         self.assertEqual(qp.tables, ['btype'])

+         self.assertEqual(qp.columns, ['id', 'name'])

+         self.assertEqual(qp.clauses, [])

+         self.assertEqual(qp.joins, None)

  

          QueryProcessor.reset_mock()

  
@@ -35,16 +35,16 @@ 

          ret = kojihub.list_btypes({'name': 'rpm'})

          QueryProcessor.assert_called_once()

          query.execute.assert_called_once()

-         self.assertEquals(ret, "return value")

+         self.assertEqual(ret, "return value")

  

          args, kwargs = QueryProcessor.call_args

-         self.assertEquals(args, ())

+         self.assertEqual(args, ())

          qp = QP(**kwargs)

-         self.assertEquals(qp.tables, ['btype'])

-         self.assertEquals(qp.columns, ['id', 'name'])

-         self.assertEquals(qp.clauses, ['btype.name = %(name)s'])

-         self.assertEquals(qp.values, {'name': 'rpm'})

-         self.assertEquals(qp.joins, None)

+         self.assertEqual(qp.tables, ['btype'])

+         self.assertEqual(qp.columns, ['id', 'name'])

+         self.assertEqual(qp.clauses, ['btype.name = %(name)s'])

+         self.assertEqual(qp.values, {'name': 'rpm'})

+         self.assertEqual(qp.joins, None)

  

          QueryProcessor.reset_mock()

  
@@ -54,17 +54,17 @@ 

          ret = kojihub.list_btypes({'id': 1}, {'order': 'id'})

          QueryProcessor.assert_called_once()

          query.execute.assert_called_once()

-         self.assertEquals(ret, "return value")

+         self.assertEqual(ret, "return value")

  

          args, kwargs = QueryProcessor.call_args

-         self.assertEquals(args, ())

+         self.assertEqual(args, ())

          qp = QP(**kwargs)

-         self.assertEquals(qp.tables, ['btype'])

-         self.assertEquals(qp.columns, ['id', 'name'])

-         self.assertEquals(qp.clauses, ['btype.id = %(id)s'])

-         self.assertEquals(qp.values, {'id': 1})

-         self.assertEquals(qp.opts, {'order': 'id'})

-         self.assertEquals(qp.joins, None)

+         self.assertEqual(qp.tables, ['btype'])

+         self.assertEqual(qp.columns, ['id', 'name'])

+         self.assertEqual(qp.clauses, ['btype.id = %(id)s'])

+         self.assertEqual(qp.values, {'id': 1})

+         self.assertEqual(qp.opts, {'order': 'id'})

+         self.assertEqual(qp.joins, None)

  

          QueryProcessor.reset_mock()

  

@@ -45,7 +45,7 @@ 

          package = 'test-package'

          kojihub.get_package_id.return_value = None

          rv = self.exports.listBuilds(packageID=package)

-         self.assertEquals(rv, [])

+         self.assertEqual(rv, [])

  

      @mock.patch('kojihub.get_package_id')

      def test_package_string(self, get_package_id):
@@ -57,27 +57,27 @@ 

          self.assertEqual(len(self.queries), 1)

          args, kwargs = self.QueryProcessor.call_args

          qp = QP(**kwargs)

-         self.assertEquals(qp.tables, ['build'])

-         self.assertEquals(qp.columns, ['build.id', 'build.completion_time',

-                                        'EXTRACT(EPOCH FROM build.completion_time)',

-                                        'events.id', 'events.time',

-                                        'EXTRACT(EPOCH FROM events.time)', 'build.epoch',

-                                        'build.extra', 'package.name',

-                                        "package.name || '-' || build.version || '-' || "

-                                        "build.release", 'users.id', 'users.name', 'package.id',

-                                        'package.name', 'build.release', 'build.source',

-                                        'build.start_time', 'EXTRACT(EPOCH FROM build.start_time)',

-                                        'build.state', 'build.task_id', 'build.version',

-                                        'volume.id', 'volume.name'])

+         self.assertEqual(qp.tables, ['build'])

+         self.assertEqual(qp.columns, ['build.id', 'build.completion_time',

+                                       'EXTRACT(EPOCH FROM build.completion_time)',

+                                       'events.id', 'events.time',

+                                       'EXTRACT(EPOCH FROM events.time)', 'build.epoch',

+                                       'build.extra', 'package.name',

+                                       "package.name || '-' || build.version || '-' || "

+                                       "build.release", 'users.id', 'users.name', 'package.id',

+                                       'package.name', 'build.release', 'build.source',

+                                       'build.start_time', 'EXTRACT(EPOCH FROM build.start_time)',

+                                       'build.state', 'build.task_id', 'build.version',

+                                       'volume.id', 'volume.name'])

          self.assertEqual(qp.clauses, ['package.id = %(packageID)i'])

-         self.assertEquals(qp.joins, ['LEFT JOIN events ON build.create_event = events.id',

-                                      'LEFT JOIN package ON build.pkg_id = package.id',

-                                      'LEFT JOIN volume ON build.volume_id = volume.id',

-                                      'LEFT JOIN users ON build.owner = users.id'])

+         self.assertEqual(qp.joins, ['LEFT JOIN events ON build.create_event = events.id',

+                                     'LEFT JOIN package ON build.pkg_id = package.id',

+                                     'LEFT JOIN volume ON build.volume_id = volume.id',

+                                     'LEFT JOIN users ON build.owner = users.id'])

  

      @mock.patch('kojihub.get_user')

      def test_wrong_user(self, get_user):

          user = 'test-user'

          get_user.return_value = None

          rv = self.exports.listBuilds(userID=user)

-         self.assertEquals(rv, [])

+         self.assertEqual(rv, [])

@@ -47,64 +47,63 @@ 

      def test_task_unwait(self, context, processor):

          host = kojihub.Host(id=1234)

          host.taskUnwait(parent=123)

-         self.assertEquals(len(processor.mock_calls), 6)

+         self.assertEqual(len(processor.mock_calls), 6)

          update1 = mock.call(

              'task',

              clauses=['id=%(parent)s'],

              values=mock.ANY,

          )

-         self.assertEquals(processor.call_args_list[0], update1)

+         self.assertEqual(processor.call_args_list[0], update1)

          update2 = mock.call(

              'task',

              clauses=['parent=%(parent)s'],

              values=mock.ANY,

          )

-         self.assertEquals(processor.call_args_list[1], update2)

- 

+         self.assertEqual(processor.call_args_list[1], update2)

  

      @mock.patch('kojihub.UpdateProcessor')

      @mock.patch('kojihub.context')

      def test_task_set_wait_all_tasks(self, context, processor):

          host = kojihub.Host(id=1234)

          host.taskSetWait(parent=123, tasks=None)

-         self.assertEquals(len(processor.mock_calls), 6)

+         self.assertEqual(len(processor.mock_calls), 6)

          update1 = mock.call(

              'task',

              clauses=['id=%(parent)s'],

              values=mock.ANY,

          )

-         self.assertEquals(processor.call_args_list[0], update1)

+         self.assertEqual(processor.call_args_list[0], update1)

          update2 = mock.call(

              'task',

              clauses=['parent=%(parent)s'],

              values=mock.ANY,

          )

-         self.assertEquals(processor.call_args_list[1], update2)

+         self.assertEqual(processor.call_args_list[1], update2)

  

      @mock.patch('kojihub.UpdateProcessor')

      @mock.patch('kojihub.context')

      def test_task_set_wait_some_tasks(self, context, processor):

          host = kojihub.Host(id=1234)

          host.taskSetWait(parent=123, tasks=[234, 345])

-         self.assertEquals(len(processor.mock_calls), 9)

+         self.assertEqual(len(processor.mock_calls), 9)

          update1 = mock.call(

              'task',

              clauses=['id=%(parent)s'],

              values=mock.ANY,

          )

-         self.assertEquals(processor.call_args_list[0], update1)

+         self.assertEqual(processor.call_args_list[0], update1)

          update2 = mock.call(

              'task',

              clauses=['id IN %(tasks)s', 'parent=%(parent)s'],

              values=mock.ANY,

          )

-         self.assertEquals(processor.call_args_list[1], update2)

+         self.assertEqual(processor.call_args_list[1], update2)

          update3 = mock.call(

              'task',

              clauses=['id NOT IN %(tasks)s', 'parent=%(parent)s', 'awaited=true'],

              values=mock.ANY,

          )

-         self.assertEquals(processor.call_args_list[2], update3)

+         self.assertEqual(processor.call_args_list[2], update3)

  

      @mock.patch('kojihub.context')

      def test_task_wait_check(self, context):
@@ -119,8 +118,8 @@ 

          host = kojihub.Host(id=1234)

          finished, unfinished = host.taskWaitCheck(parent=123)

          cursor.execute.assert_called_once()

-         self.assertEquals(finished, [2, 3])

-         self.assertEquals(unfinished, [1, 4])

+         self.assertEqual(finished, [2, 3])

+         self.assertEqual(unfinished, [1, 4])

  

      @mock.patch('kojihub.context')

      def test_task_wait(self, context):
@@ -134,4 +133,4 @@ 

          ]

          host = kojihub.Host(id=1234)

          host.taskWait(parent=123)

-         self.assertEquals(len(cursor.execute.mock_calls), 3)

+         self.assertEqual(len(cursor.execute.mock_calls), 3)

@@ -1,4 +1,5 @@ 

  import mock

+ import unittest

  

  import koji

  import kojihub
@@ -6,14 +7,12 @@ 

  QP = kojihub.QueryProcessor

  UP = kojihub.UpdateProcessor

  

- class TestRecycleBuild():

-     # NOT a subclass of unittest.TestCase so that we can use generator

-     # methods

  

+ class TestRecycleBuild(unittest.TestCase):

      def setUp(self):

          self.QueryProcessor = mock.patch('kojihub.QueryProcessor').start()

          self.UpdateProcessor = mock.patch('kojihub.UpdateProcessor',

-                                 side_effect=self.getUpdate).start()

+                                           side_effect=self.getUpdate).start()

          self._dml = mock.patch('kojihub._dml').start()

          self.run_callbacks = mock.patch('koji.plugin.run_callbacks').start()

          self.rmtree = mock.patch('koji.util.rmtree').start()
@@ -70,6 +69,17 @@ 

          self._dml.assert_not_called()

          self.run_callbacks.assert_not_called()

  

+     def run_fail(self, old, new):

+         try:

+             kojihub.recycle_build(old, new)

+         except koji.GenericError:

+             pass

+         else:

+             raise Exception("expected koji.GenericError")

+         self.UpdateProcessor.assert_not_called()

+         self._dml.assert_not_called()

+         self.run_callbacks.assert_not_called()

+ 

      def test_recycle_building_bad(self):

          new = self.new.copy()

          old = self.old.copy()
@@ -109,17 +119,6 @@ 

          assert update.clauses == ['id=%(id)s']

          assert update.values['id'] == old['id']

  

-     def run_fail(self, old, new):

-         try:

-             kojihub.recycle_build(old, new)

-         except koji.GenericError:

-             pass

-         else:

-             raise Exception("expected koji.GenericError")

-         self.UpdateProcessor.assert_not_called()

-         self._dml.assert_not_called()

-         self.run_callbacks.assert_not_called()

- 

      def test_recycle_states_bad(self):

          for state in 'BUILDING', 'COMPLETE', 'DELETED':

              yield self.check_recycle_states_bad, koji.BUILD_STATES[state]
@@ -139,7 +138,7 @@ 

              [[], [], True],

              [True, [], []],

              [[], True, []],

-             ]

+         ]

          for values in vlists:

              yield self.check_recycle_query_bad, values

  
@@ -153,4 +152,3 @@ 

          query = self.QueryProcessor.return_value

          query.execute.side_effect = values

          self.run_fail(old, new)

- 

@@ -22,7 +22,8 @@ 

          d.differs.return_value = False

          Rpmdiff.return_value = d

          self.assertFalse(kojihub.rpmdiff('basepath', ['12/1234/foo', '23/2345/bar'], hashes={}))

-         Rpmdiff.assert_called_once_with('basepath/12/1234/foo', 'basepath/23/2345/bar', ignore='S5TN')

+         Rpmdiff.assert_called_once_with(

+             'basepath/12/1234/foo', 'basepath/23/2345/bar', ignore='S5TN')

  

      @mock.patch('koji.rpmdiff.Rpmdiff')

      def test_rpmdiff_simple_failure(self, Rpmdiff):
@@ -31,7 +32,8 @@ 

          Rpmdiff.return_value = d

          with self.assertRaises(koji.BuildError):

              kojihub.rpmdiff('basepath', ['12/1234/foo', '13/1345/bar'], hashes={})

-         Rpmdiff.assert_called_once_with('basepath/12/1234/foo', 'basepath/13/1345/bar', ignore='S5TN')

+         Rpmdiff.assert_called_once_with(

+             'basepath/12/1234/foo', 'basepath/13/1345/bar', ignore='S5TN')

          d.textdiff.assert_called_once_with()

  

      def test_rpmdiff_real_target(self):
@@ -88,10 +90,11 @@ 

          # dummy file info

          defattr = [19, 33188, 1531970408, 0, 0, 2, 1, -1, -1, 'root', 'root', '02d2c91b']

  

-         rpm_dict_old = {'a_file': defattr }

+         rpm_dict_old = {'a_file': defattr}

  

          def check_diff_result(opt, idx, value, textdiff):

              orig_init = koji.rpmdiff.Rpmdiff.__init__

+ 

              def init_mock(*args, **kwargs):

                  # need to init rpm_dict every time

                  attr = defattr[:]
@@ -147,14 +150,14 @@ 

      def test_check_noarch_rpms_empty_invocation(self, rpmdiff):

          originals = ['foo', 'bar']

          result = kojihub.check_noarch_rpms('basepath', copy.copy(originals))

-         self.assertEquals(result, originals)

+         self.assertEqual(result, originals)

  

      @mock.patch('kojihub.rpmdiff')

      def test_check_noarch_rpms_simple_invocation(self, rpmdiff):

          originals = ['12/1234/foo.noarch.rpm', '23/2345/foo.noarch.rpm']

          result = kojihub.check_noarch_rpms('basepath', copy.copy(originals))

-         self.assertEquals(result, originals[0:1])

-         self.assertEquals(len(rpmdiff.mock_calls), 1)

+         self.assertEqual(result, originals[0:1])

+         self.assertEqual(len(rpmdiff.mock_calls), 1)

  

      @mock.patch('kojihub.rpmdiff')

      def test_check_noarch_rpms_with_duplicates(self, rpmdiff):
@@ -164,7 +167,7 @@ 

              'bar.noarch.rpm',

          ]

          result = kojihub.check_noarch_rpms('basepath', copy.copy(originals))

-         self.assertEquals(result, ['bar.noarch.rpm'])

+         self.assertEqual(result, ['bar.noarch.rpm'])

          rpmdiff.assert_called_once_with('basepath', originals, hashes={})

  

      @mock.patch('kojihub.rpmdiff')
@@ -176,7 +179,7 @@ 

              'bar.noarch.rpm',

          ]

          result = kojihub.check_noarch_rpms('basepath', copy.copy(originals))

-         self.assertEquals(result, [

+         self.assertEqual(result, [

              'foo.x86_64.rpm', 'bar.x86_64.rpm', 'bar.noarch.rpm'

          ])

          rpmdiff.assert_called_once_with(

@@ -13,13 +13,13 @@ 

          proc = kojihub.UpdateProcessor('sometable', data={'foo': 'bar'})

          actual = str(proc)

          expected = 'UPDATE sometable SET foo = %(data.foo)s'

-         self.assertEquals(actual, expected)

+         self.assertEqual(actual, expected)

  

      def test_to_values_from_data(self):

          proc = kojihub.UpdateProcessor('sometable', data={'foo': 'bar'})

          actual = proc.get_values()

          expected = {'data.foo': 'bar'}

-         self.assertEquals(actual, expected)

+         self.assertEqual(actual, expected)

  

      @mock.patch('kojihub.context')

      def test_simple_execution_with_iterate(self, context):

@@ -5,7 +5,6 @@ 

  import unittest

  

  import koji

- from koji.xmlrpcplus import Fault

  

  

  class TestClientSession(unittest.TestCase):
@@ -84,8 +83,8 @@ 

          fileobj.read.side_effect = ['123123', '']

          self.file_mock.return_value = fileobj

          self.ksession._callMethod.side_effect = [

-             {'size': 6, 'hexdigest': '041c012d'}, # rawUpload

-             {'size': 6, 'hexdigest': '041c012d'}, # checkUpload

+             {'size': 6, 'hexdigest': '041c012d'},  # rawUpload

+             {'size': 6, 'hexdigest': '041c012d'},  # checkUpload

          ]

          self.ksession.fastUpload('file', 'target', blocksize=1024)

  
@@ -96,8 +95,8 @@ 

          self.file_mock.return_value = fileobj

          self.getsize_mock.return_value = 123456

          self.ksession._callMethod.side_effect = [

-             {'size': 6, 'hexdigest': '041c012d'}, # rawUpload

-             {'size': 6, 'hexdigest': '041c012d'}, # checkUpload

+             {'size': 6, 'hexdigest': '041c012d'},  # rawUpload

+             {'size': 6, 'hexdigest': '041c012d'},  # checkUpload

          ]

          self.ksession.fastUpload('file', 'target', blocksize=1024)

  
@@ -108,8 +107,8 @@ 

          self.file_mock.return_value = fileobj

          self.getsize_mock.return_value = 123456

          self.ksession._callMethod.side_effect = [

-             {'size': 6, 'hexdigest': '041c012d'}, # rawUpload

-             {'size': 3, 'hexdigest': '041c012d'}, # checkUpload

+             {'size': 6, 'hexdigest': '041c012d'},  # rawUpload

+             {'size': 3, 'hexdigest': '041c012d'},  # checkUpload

          ]

          with self.assertRaises(koji.GenericError):

              self.ksession.fastUpload('file', 'target', blocksize=1024)
@@ -121,8 +120,8 @@ 

          self.file_mock.return_value = fileobj

          self.getsize_mock.return_value = 123456

          self.ksession._callMethod.side_effect = [

-             {'size': 6, 'hexdigest': '041c012d'}, # rawUpload

-             {'size': 3, 'hexdigest': 'deadbeef'}, # checkUpload

+             {'size': 6, 'hexdigest': '041c012d'},  # rawUpload

+             {'size': 3, 'hexdigest': 'deadbeef'},  # checkUpload

          ]

          with self.assertRaises(koji.GenericError):

              self.ksession.fastUpload('file', 'target', blocksize=1024)
@@ -133,8 +132,8 @@ 

          fileobj.read.side_effect = ['123123', '']

          self.file_mock.return_value = fileobj

          self.ksession._callMethod.side_effect = [

-             {'size': 6, 'hexdigest': '041c012d'}, # rawUpload

-             {'size': 6, 'hexdigest': '041c012d'}, # checkUpload

+             {'size': 6, 'hexdigest': '041c012d'},  # rawUpload

+             {'size': 6, 'hexdigest': '041c012d'},  # checkUpload

          ]

          self.ksession.fastUpload('file', 'target', blocksize=1024, volume='foobar')

          for call in self.ksession._callMethod.call_args_list:
@@ -171,8 +170,7 @@ 

          self.ksession._sendCall.assert_not_called()

  

      def test_multiCall_strict(self):

-         self.ksession._sendCall.return_value = [[], {'faultCode': 1000,

-                                                'faultString': 'msg'}]

+         self.ksession._sendCall.return_value = [[], {'faultCode': 1000, 'faultString': 'msg'}]

          self.ksession.multicall = True

          self.ksession.methodA('a', 'b', c='c')

          self.ksession.methodB(1, 2, 3)
@@ -204,7 +202,7 @@ 

  

      def test_MultiCallHack_weakref_validation(self):

          expected_exc = 'The session parameter must be a weak reference'

-         with self.assertRaisesRegexp(TypeError, expected_exc):

+         with self.assertRaisesRegex(TypeError, expected_exc):

              koji.MultiCallHack(self.ksession)

  

          # This should not raise an exception

@@ -84,7 +84,7 @@ 

          self.assertEqual(newfunc(1, 2, 3), [1, 2, 3])

  

  

- class TestError(Exception):

+ class ErrorTest(Exception):

      """Raised by a test callback defined below"""

      pass

  
@@ -103,12 +103,12 @@ 

          self.callbacks.append([cbtype, args, kwargs])

  

      def error_callback(self, cbtype, *args, **kwargs):

-         raise TestError

+         raise ErrorTest

  

      @koji.plugin.ignore_error

      def safe_error_callback(self, cbtype, *args, **kwargs):

          self.callbacks.append([cbtype, args, kwargs])

-         raise TestError

+         raise ErrorTest

  

      @koji.plugin.convert_datetime

      def datetime_callback(self, cbtype, *args, **kwargs):
@@ -299,8 +299,8 @@ 

  

      @mock.patch('logging.getLogger')

      def test_bad_plugin(self, getLogger):

-         self._set_module_side_effect(TestError)

-         with self.assertRaises(TestError):

+         self._set_module_side_effect(ErrorTest)

+         with self.assertRaises(ErrorTest):

              self.tracker.load('hello')

          self.assertEqual(self.tracker.get('hello'), None)

          getLogger.assert_called_once()

file modified
+16 -16
@@ -1,7 +1,7 @@ 

  from __future__ import absolute_import

  import unittest

+ import pytest

  

- from nose.tools import raises

  

  import koji.policy

  
@@ -24,10 +24,10 @@ 

  

  class TestBasicTests(unittest.TestCase):

  

-     @raises(NotImplementedError)

      def test_base_test(self):

-         obj = koji.policy.BaseSimpleTest('something')

-         obj.run({})

+         with pytest.raises(NotImplementedError):

+             obj = koji.policy.BaseSimpleTest('something')

+             obj.run({})

  

      def test_true_test(self):

          obj = koji.policy.TrueTest('something')
@@ -108,9 +108,9 @@ 

          self.assertTrue(obj.run({'thing': 0}))

          self.assertFalse(obj.run({}))

  

-     @raises(koji.GenericError)

      def test_invalid_compare_test(self):

-         koji.policy.CompareTest('some thing LOL 2')

+         with pytest.raises(koji.GenericError):

+             koji.policy.CompareTest('some thing LOL 2')

  

  

  class TestDiscovery(unittest.TestCase):
@@ -143,7 +143,7 @@ 

          rules = ['true :: allow']

          obj = koji.policy.SimpleRuleSet(rules, tests)

          result = obj.all_actions()

-         self.assertEquals(result, ['allow'])

+         self.assertEqual(result, ['allow'])

  

      def test_simple_rule_set_apply(self):

          tests = koji.policy.findSimpleTests(koji.policy.__dict__)
@@ -164,18 +164,18 @@ 

  

          rules = ['bool_check :: True', 'all :: False']

          for val in True, False:

-             data = {'bool_field' : val}

+             data = {'bool_field': val}

              obj = koji.policy.SimpleRuleSet(rules, tests)

              action = obj.apply(data)

              self.assertEqual(action, str(val))

  

          rules = ['match_check foo* :: foo', 'match_check * :: bar']

-         data = {'match_field' : 'foo1234'}

+         data = {'match_field': 'foo1234'}

          obj = koji.policy.SimpleRuleSet(rules, tests)

          action = obj.apply(data)

          self.assertEqual(action, 'foo')

  

-         data = {'match_field' : 'not foo'}

+         data = {'match_field': 'not foo'}

          obj = koji.policy.SimpleRuleSet(rules, tests)

          action = obj.apply(data)

          self.assertEqual(action, 'bar')
@@ -197,21 +197,21 @@ 

          # no match

          rules = ['none :: allow']

          obj = koji.policy.SimpleRuleSet(rules, tests)

-         self.assertEquals(obj.last_rule(), None)

+         self.assertEqual(obj.last_rule(), None)

          action = obj.apply(data)

-         self.assertEquals(obj.last_rule(), '(no match)')

+         self.assertEqual(obj.last_rule(), '(no match)')

  

          # simple rule

          rules = ['all :: allow']

          obj = koji.policy.SimpleRuleSet(rules, tests)

          action = obj.apply(data)

-         self.assertEquals(obj.last_rule(), rules[0])

+         self.assertEqual(obj.last_rule(), rules[0])

  

          # negate rule

          rules = ['none !! allow']

          obj = koji.policy.SimpleRuleSet(rules, tests)

          action = obj.apply(data)

-         self.assertEquals(obj.last_rule(), rules[0])

+         self.assertEqual(obj.last_rule(), rules[0])

  

          # nested rule

          policy = '''
@@ -225,7 +225,7 @@ 

          obj = koji.policy.SimpleRuleSet(rules, tests)

          action = obj.apply(data)

          expected = 'all :: ... all :: ... all :: allow'

-         self.assertEquals(obj.last_rule(), expected)

+         self.assertEqual(obj.last_rule(), expected)

  

      def test_unclosed_brace(self):

          tests = koji.policy.findSimpleTests(koji.policy.__dict__)
@@ -311,4 +311,4 @@ 

          self.assertEqual(action, 'END')

  

          actions = set(obj.all_actions())

-         self.assertEquals(actions, set(['1', '2', '3', '4', 'ERROR', 'END']))

+         self.assertEqual(actions, set(['1', '2', '3', '4', 'ERROR', 'END']))

@@ -8,6 +8,7 @@ 

  

  import unittest

  

+ 

  class ProfilesTestCase(unittest.TestCase):

  

      def test_profile_threading(self):
@@ -34,11 +35,8 @@ 

          config = mock.Mock(topdir='topdir')

          koji.get_profile_module('koji', config=config)

      except Exception:

-         # if we don't catch this, nose seems to ignore the test

+         # if we don't catch this, pytest seems to ignore the test

          errors[n] = ''.join(traceback.format_exception(*sys.exc_info()))

          return

      else:

          errors[n] = None

- 

- 

- 

file modified
+211 -173
@@ -11,9 +11,8 @@ 

  import requests_mock

  

  import koji

- from koji.tasks import BaseTaskHandler, FakeTask, ForkTask, SleepTask, \

-                        WaitTestTask, scan_mounts, umount_all, \

-                        safe_rmtree

+ from koji.tasks import BaseTaskHandler, FakeTask, ForkTask, SleepTask, WaitTestTask, scan_mounts, \

+     umount_all, safe_rmtree

  

  

  def get_fake_mounts_file():
@@ -49,10 +48,11 @@ 

  

  

  def get_tmp_dir_path(folder_starts_with):

-     return path.join(get_temp_dir_root(), ('{0}{1}'.format(folder_starts_with, random.randint(1, 999999999999))))

+     return path.join(get_temp_dir_root(), (

+         '{0}{1}'.format(folder_starts_with, random.randint(1, 999999999999))))

  

  

- class TestTask(BaseTaskHandler):

+ class TaskTest(BaseTaskHandler):

      Methods = ['some_method']

      _taskWeight = 5.2

  
@@ -60,7 +60,7 @@ 

          return 42

  

  

- class TestTaskNoWeight(BaseTaskHandler):

+ class TaskNoWeightTest(BaseTaskHandler):

      Methods = ['some_method']

  

      def handler(self, *args):
@@ -80,32 +80,36 @@ 

              shutil.rmtree(get_temp_dir_root())

  

      def test_scan_mounts_results(self):

-         """ Tests the scan_mounts function with a mocked /proc/mounts file. A list containing mount points

-         starting with /dev are expected to be returned from the function based on the function input of /dev.

+         """ Tests the scan_mounts function with a mocked /proc/mounts file.

+         A list containing mount points starting with /dev are expected to be returned

+         from the function based on the function input of /dev.

          """

          fake_mounts_file_contents = get_fake_mounts_file()

  

          with patch('koji.tasks.open', return_value=fake_mounts_file_contents, create=True):

-             self.assertIn(scan_mounts('/dev'), [['/dev/shm', '/dev/pts', '/dev/mqueue', '/dev/hugepages', '/dev']])

+             self.assertIn(scan_mounts('/dev'),

+                           [['/dev/shm', '/dev/pts', '/dev/mqueue', '/dev/hugepages', '/dev']])

  

      def test_scan_mounts_no_results(self):

-         """ Tests the scan_mounts function with a mocked /proc/mounts file. An argument of /nonexistent/path

-         to the function should return an empty list.

+         """ Tests the scan_mounts function with a mocked /proc/mounts file.

+         An argument of /nonexistent/path to the function should return an empty list.

          """

          fake_mounts_file_contents = get_fake_mounts_file()

  

          with patch('koji.tasks.open', return_value=fake_mounts_file_contents, create=True):

-             self.assertEquals(scan_mounts('/nonexistent/path'), [])

+             self.assertEqual(scan_mounts('/nonexistent/path'), [])

  

-     # Patching the scan_mounts function instead of the built-in open function because this is only testing umount_all

+     # Patching the scan_mounts function instead of the built-in open function

+     # because this is only testing umount_all

      @patch('koji.tasks.scan_mounts', side_effect=[['/dev/shm', '/dev/pts', '/dev/mqueue'], []])

      @patch('os.spawnvp', return_value=0)

      def test_umount_all(self, mocked_spawnvp, mocked_scan_mounts):

          """ Tests that umount_all returns nothing when successful.

          """

-         self.assertEquals(umount_all('/test'), None)

+         self.assertEqual(umount_all('/test'), None)

  

-     # Patching the scan_mounts function instead of the built-in open function because this is only testing umount_all

+     # Patching the scan_mounts function instead of the built-in open function

+     # because this is only testing umount_all

      @patch('koji.tasks.scan_mounts', return_value=['/dev/shm', '/dev/pts', '/dev/mqueue'])

      @patch('os.spawnvp', return_value=1)

      def test_umount_all_failure(self, mocked_spawnvp, mocked_scan_mounts):
@@ -115,83 +119,91 @@ 

              umount_all('/dev')

              raise Exception('A GenericError was not raised during the test')

          except koji.GenericError as e:

-             self.assertEquals(e.args[0],

-                               'umount failed (exit code 1) for /dev/shm')

+             self.assertEqual(e.args[0], 'umount failed (exit code 1) for /dev/shm')

  

-     # Patching the scan_mounts function instead of the built-in open function because this is only testing umount_all

-     @patch('koji.tasks.scan_mounts', side_effect=[['/dev/shm', '/dev/pts', '/dev/mqueue'], ['/dev/shm', '/dev/mqueue']])

+     # Patching the scan_mounts function instead of the built-in open function

+     # because this is only testing umount_all

+     @patch('koji.tasks.scan_mounts',

+            side_effect=[['/dev/shm', '/dev/pts', '/dev/mqueue'], ['/dev/shm', '/dev/mqueue']])

      @patch('os.spawnvp', return_value=0)

      def test_umount_all_unexpected_failure(self, mocked_spawnvp, mocked_scan_mounts):

-         """ Tests that umount_all will fail if the command to unmount the mount points was successful

-         but a second run of scan_mounts still shows some of the unmount mount points still mounted.

+         """ Tests that umount_all will fail if the command to unmount the mount

+         points was successful but a second run of scan_mounts still shows some of the unmount

+         mount points still mounted.

          """

          try:

              umount_all('/dev')

              raise Exception('A GenericError was not raised during the test')

          except koji.GenericError as e:

-             self.assertEquals(e.args[0], 'Unmounting incomplete: [\'/dev/shm\', \'/dev/mqueue\']')

+             self.assertEqual(e.args[0], 'Unmounting incomplete: [\'/dev/shm\', \'/dev/mqueue\']')

  

      def test_BaseTaskHandler_handler_not_set(self):

-         """ Tests that an exception is thrown when the handler function is not overwritten by the child class.

+         """ Tests that an exception is thrown when the handler function is not overwritten

+         by the child class.

          """

-         obj = BadTask(123, 'some_method', ['random_arg'], None, None, (get_tmp_dir_path('BadTask')))

+         obj = BadTask(123, 'some_method', ['random_arg'], None, None,

+                       (get_tmp_dir_path('BadTask')))

          try:

              obj.handler()

              raise Exception('The NotImplementedError exception was not raised')

          except NotImplementedError as e:

-             self.assertEquals(e.__class__.__name__, 'NotImplementedError')

+             self.assertEqual(e.__class__.__name__, 'NotImplementedError')

  

      def test_BaseTaskHandler_weight_default(self):

-         """ Tests that the weight function returns 1.0 when _taskWeight is not set in the child class' definition.

+         """ Tests that the weight function returns 1.0 when _taskWeight is not set in the child

+         class' definition.

          """

-         obj = TestTaskNoWeight(123, 'some_method', ['random_arg'], None, None, (get_tmp_dir_path('TestTaskNoWeight')))

-         self.assertEquals(obj.weight(), 1.0)

+         obj = TaskNoWeightTest(123, 'some_method', ['random_arg'], None, None,

+                                (get_tmp_dir_path('TaskNoWeightTest')))

+         self.assertEqual(obj.weight(), 1.0)

  

      def test_BaseTaskHandler_weight_set(self):

          """ Tests that the weight function returns the value of _taskWeight when it is set in the

          child class' definition.

          """

-         obj = TestTask(123, 'some_method', ['random_arg'], None, None, (get_tmp_dir_path('TestTask')))

-         self.assertEquals(obj.weight(), 5.2)

+         obj = TaskTest(123, 'some_method', ['random_arg'], None, None,

+                        (get_tmp_dir_path('TaskTest')))

+         self.assertEqual(obj.weight(), 5.2)