Pytest instead of nose in unittest
Fixes: https://pagure.io/koji/issue/3140
This commit is contained in:
parent
bbaadef417
commit
c310d6692d
34 changed files with 644 additions and 631 deletions
|
|
@ -4,10 +4,10 @@ import os
|
|||
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 @@ class TestImportComps(utils.CliTestCase):
|
|||
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 @@ class TestImportComps(utils.CliTestCase):
|
|||
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 @@ class TestImportComps(utils.CliTestCase):
|
|||
@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 @@ class TestImportComps(utils.CliTestCase):
|
|||
@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'
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class TestParseTaskParams(utils.CliTestCase):
|
|||
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 @@ class TestParseTaskParams(utils.CliTestCase):
|
|||
|
||||
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 @@ class TestParseTaskParams(utils.CliTestCase):
|
|||
|
||||
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 @@ class TestParseTaskParams(utils.CliTestCase):
|
|||
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 @@ class TestParseTaskParams(utils.CliTestCase):
|
|||
|
||||
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 @@ Build: bash-4.4.12-5.fc26 (1)
|
|||
|
||||
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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue