Drop usage of six

We no longer need to support Python 2, so there's no point in this
compatibility layer.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>

(cherry picked from commit b34de57813187f1781aef733468c9745a144d9af)
This commit is contained in:
Lubomír Sedlář 2024-11-22 15:44:16 +02:00 committed by Stepan Oksanichenko
parent b044ebdba1
commit 4ff13b1993
57 changed files with 450 additions and 745 deletions

View File

@ -42,7 +42,6 @@ import platform
import re
import jsonschema
import six
from kobo.shortcuts import force_list
from pungi.phases import PHASES_NAMES
from pungi.runroot import RUNROOT_TYPES
@ -236,8 +235,8 @@ def validate(config, offline=False, schema=None):
schema,
{
"array": (tuple, list),
"regex": six.string_types,
"url": six.string_types,
"regex": str,
"url": str,
},
)
errors = []
@ -462,7 +461,7 @@ def _extend_with_default_and_alias(validator_class, offline=False):
return isinstance(instance, (tuple, list))
def is_string_type(checker, instance):
return isinstance(instance, six.string_types)
return isinstance(instance, str)
kwargs["type_checker"] = validator_class.TYPE_CHECKER.redefine_many(
{"array": is_array, "regex": is_string_type, "url": is_string_type}

View File

@ -3,10 +3,9 @@
from __future__ import print_function
import os
import six
import shlex
from collections import namedtuple
from kobo.shortcuts import run
from six.moves import shlex_quote
from .wrappers import iso
from .wrappers.jigdo import JigdoWrapper
@ -41,13 +40,13 @@ def quote(str):
expanded.
"""
if str.startswith("$TEMPLATE"):
return "$TEMPLATE%s" % shlex_quote(str.replace("$TEMPLATE", "", 1))
return shlex_quote(str)
return "$TEMPLATE%s" % shlex.quote(str.replace("$TEMPLATE", "", 1))
return shlex.quote(str)
def emit(f, cmd):
"""Print line of shell code into the stream."""
if isinstance(cmd, six.string_types):
if isinstance(cmd, str):
print(cmd, file=f)
else:
print(" ".join([quote(x) for x in cmd]), file=f)

View File

@ -16,8 +16,7 @@
import os
import json
import six
from six.moves import shlex_quote
import shlex
from .base import OSTree
@ -26,10 +25,10 @@ from .utils import tweak_treeconf
def emit(cmd):
"""Print line of shell code into the stream."""
if isinstance(cmd, six.string_types):
if isinstance(cmd, str):
print(cmd)
else:
print(" ".join([shlex_quote(x) for x in cmd]))
print(" ".join([shlex.quote(x) for x in cmd]))
class Container(OSTree):

View File

@ -16,17 +16,17 @@
import errno
import os
import pickle
import time
import shlex
import shutil
import re
from six.moves import cPickle as pickle
from copy import copy
from kobo.threads import ThreadPool, WorkerThread
from kobo.shortcuts import run, force_list
import kobo.rpmlib
from productmd.images import Image
from six.moves import shlex_quote
from pungi.arch import get_valid_arches
from pungi.util import get_volid, get_arch_variant_data
@ -207,8 +207,8 @@ class BuildinstallPhase(PhaseBase):
configuration_file=configuration_file,
)
return "rm -rf %s && %s" % (
shlex_quote(output_topdir),
" ".join([shlex_quote(x) for x in lorax_cmd]),
shlex.quote(output_topdir),
" ".join([shlex.quote(x) for x in lorax_cmd]),
)
def get_repos(self, arch):
@ -413,8 +413,8 @@ def tweak_buildinstall(
# copy src to temp
# TODO: place temp on the same device as buildinstall dir so we can hardlink
cmd = "cp -dRv --preserve=mode,links,timestamps --remove-destination %s/* %s/" % (
shlex_quote(src),
shlex_quote(tmp_dir),
shlex.quote(src),
shlex.quote(tmp_dir),
)
run(cmd)
@ -452,12 +452,12 @@ def tweak_buildinstall(
run(cmd)
# HACK: make buildinstall files world readable
run("chmod -R a+rX %s" % shlex_quote(tmp_dir))
run("chmod -R a+rX %s" % shlex.quote(tmp_dir))
# copy temp to dst
cmd = "cp -dRv --preserve=mode,links,timestamps --remove-destination %s/* %s/" % (
shlex_quote(tmp_dir),
shlex_quote(dst),
shlex.quote(tmp_dir),
shlex.quote(dst),
)
run(cmd)

View File

@ -17,6 +17,7 @@
import itertools
import os
import random
import shlex
import shutil
import stat
import json
@ -25,7 +26,6 @@ import productmd.treeinfo
from productmd.images import Image
from kobo.threads import ThreadPool, WorkerThread
from kobo.shortcuts import run, relative_path, compute_file_checksums
from six.moves import shlex_quote
from pungi.wrappers import iso
from pungi.wrappers.createrepo import CreaterepoWrapper
@ -782,7 +782,7 @@ def prepare_iso(
if file_list_content:
# write modified repodata only if there are packages available
run("cp -a %s/repodata %s/" % (shlex_quote(tree_dir), shlex_quote(iso_dir)))
run("cp -a %s/repodata %s/" % (shlex.quote(tree_dir), shlex.quote(iso_dir)))
with open(file_list, "w") as f:
f.write("\n".join(file_list_content))
cmd = repo.get_createrepo_cmd(

View File

@ -17,6 +17,7 @@
import glob
import json
import os
import pickle
import shutil
import threading
@ -24,7 +25,6 @@ from kobo.rpmlib import parse_nvra
from kobo.shortcuts import run
from productmd.rpms import Rpms
from pungi.phases.pkgset.common import get_all_arches
from six.moves import cPickle as pickle
try:
from queue import Queue

View File

@ -16,7 +16,6 @@
import os
from pprint import pformat
import re
import six
import pungi.arch
from pungi.util import pkg_is_rpm, pkg_is_srpm, pkg_is_debug
@ -74,7 +73,7 @@ class GatherMethodNodeps(pungi.phases.gather.method.GatherMethodBase):
if not pkg_is_rpm(pkg):
continue
for gathered_pkg, pkg_arch in packages:
if isinstance(gathered_pkg, six.string_types) and not re.match(
if isinstance(gathered_pkg, str) and not re.match(
gathered_pkg.replace(".", "\\.")
.replace("+", "\\+")
.replace("*", ".*")

View File

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import configparser
import copy
import fnmatch
import json
@ -7,7 +8,6 @@ import os
from kobo.threads import ThreadPool, WorkerThread
from kobo import shortcuts
from productmd.rpms import Rpms
from six.moves import configparser
from .base import ConfigGuardedPhase, PhaseLoggerMixin
from .. import util

View File

@ -2,9 +2,9 @@
import os
from kobo.threads import ThreadPool, WorkerThread
import shlex
import shutil
from productmd import images
from six.moves import shlex_quote
from kobo import shortcuts
from .base import ConfigGuardedPhase, PhaseLoggerMixin
@ -275,8 +275,8 @@ class OstreeInstallerThread(WorkerThread):
skip_branding=config.get("skip_branding"),
)
cmd = "rm -rf %s && %s" % (
shlex_quote(output_dir),
" ".join([shlex_quote(x) for x in lorax_cmd]),
shlex.quote(output_dir),
" ".join([shlex.quote(x) for x in lorax_cmd]),
)
runroot.run(

View File

@ -22,10 +22,10 @@ It automatically finds a signed copies according to *sigkey_ordering*.
import itertools
import json
import os
import pickle
import time
import pgpy
import rpm
from six.moves import cPickle as pickle
from functools import partial
import kobo.log

View File

@ -16,12 +16,11 @@
import contextlib
import os
import re
import shlex
import shutil
import tarfile
import requests
import six
from six.moves import shlex_quote
import kobo.log
from kobo.shortcuts import run
@ -157,7 +156,7 @@ class Runroot(kobo.log.LoggingBase):
formatted_cmd = command.format(**fmt_dict) if fmt_dict else command
ssh_cmd = ["ssh", "-oBatchMode=yes", "-n", "-l", user, hostname, formatted_cmd]
output = run(ssh_cmd, show_cmd=True, logfile=log_file)[1]
if six.PY3 and isinstance(output, bytes):
if isinstance(output, bytes):
return output.decode()
else:
return output
@ -184,7 +183,7 @@ class Runroot(kobo.log.LoggingBase):
# If the output dir is defined, change the permissions of files generated
# by the runroot task, so the Pungi user can access them.
if chown_paths:
paths = " ".join(shlex_quote(pth) for pth in chown_paths)
paths = " ".join(shlex.quote(pth) for pth in chown_paths)
command += " ; EXIT_CODE=$?"
# Make the files world readable
command += " ; chmod -R a+r %s" % paths

View File

@ -4,13 +4,12 @@ from __future__ import absolute_import
from __future__ import print_function
import argparse
import configparser
import json
import os
import shutil
import sys
from six.moves import configparser
import kobo.conf
import pungi.checks
import pungi.util

View File

@ -8,8 +8,6 @@ import json
import os
import sys
import six
import pungi.checks
import pungi.compose
import pungi.paths
@ -56,7 +54,7 @@ class ValidationCompose(pungi.compose.Compose):
def read_variants(compose, config):
with pungi.util.temp_dir() as tmp_dir:
scm_dict = compose.conf["variants_file"]
if isinstance(scm_dict, six.string_types) and scm_dict[0] != "/":
if isinstance(scm_dict, str) and scm_dict[0] != "/":
config_dir = os.path.dirname(config)
scm_dict = os.path.join(config_dir, scm_dict)
files = pungi.wrappers.scm.get_file_from_scm(scm_dict, tmp_dir)

View File

@ -11,14 +11,13 @@ import locale
import logging
import os
import socket
import shlex
import signal
import sys
import traceback
import shutil
import subprocess
from six.moves import shlex_quote
from pungi.phases import PHASES_NAMES
from pungi import get_full_version, util
from pungi.errors import UnsignedPackagesError
@ -386,7 +385,7 @@ def run_compose(
compose.log_info("User name: %s" % getpass.getuser())
compose.log_info("Working directory: %s" % os.getcwd())
compose.log_info(
"Command line: %s" % " ".join([shlex_quote(arg) for arg in sys.argv])
"Command line: %s" % " ".join([shlex.quote(arg) for arg in sys.argv])
)
compose.log_info("Compose top directory: %s" % compose.topdir)
compose.log_info("Current timezone offset: %s" % pungi.util.get_tz_offset())

View File

@ -24,11 +24,13 @@ import hashlib
import errno
import re
import contextlib
import shlex
import traceback
import tempfile
import time
import urllib.parse
import urllib.request
import functools
from six.moves import urllib, range, shlex_quote
import kobo.conf
from kobo.shortcuts import run, force_list
@ -193,14 +195,14 @@ def explode_rpm_package(pkg_path, target_dir):
try:
# rpm2archive writes to stdout only if reading from stdin, thus the redirect
run(
"rpm2archive - <%s | tar xfz - && chmod -R a+rX ." % shlex_quote(pkg_path),
"rpm2archive - <%s | tar xfz - && chmod -R a+rX ." % shlex.quote(pkg_path),
workdir=target_dir,
)
except RuntimeError:
# Fall back to rpm2cpio in case rpm2archive failed (most likely due to
# not being present on the system).
run(
"rpm2cpio %s | cpio -iuvmd && chmod -R a+rX ." % shlex_quote(pkg_path),
"rpm2cpio %s | cpio -iuvmd && chmod -R a+rX ." % shlex.quote(pkg_path),
workdir=target_dir,
)

View File

@ -15,9 +15,9 @@
import os
import shlex
from fnmatch import fnmatch
import contextlib
from six.moves import shlex_quote
from kobo.shortcuts import force_list, relative_path, run
from pungi import util
@ -270,13 +270,13 @@ def get_manifest_cmd(iso_name, xorriso=False, output_file=None):
tr -d "'" |
cut -c2- |
sort >> %s""" % (
shlex_quote(iso_name),
shlex_quote(output_file),
shlex.quote(iso_name),
shlex.quote(output_file),
)
else:
return "isoinfo -R -f -i %s | grep -v '/TRANS.TBL$' | sort >> %s" % (
shlex_quote(iso_name),
shlex_quote(output_file),
shlex.quote(iso_name),
shlex.quote(output_file),
)

View File

@ -14,21 +14,21 @@
# along with this program; if not, see <https://gnu.org/licenses/>.
import configparser
import contextlib
import os
import re
import socket
import shlex
import shutil
import time
import threading
import xmlrpc.client
import requests
import koji
from kobo.shortcuts import run, force_list
import six
from six.moves import configparser, shlex_quote
import six.moves.xmlrpc_client as xmlrpclib
from flufl.lock import Lock
from datetime import timedelta
@ -74,7 +74,7 @@ class KojiWrapper(object):
# This retry should be removed once https://pagure.io/koji/issue/3170 is
# fixed and released.
@util.retry(wait_on=(xmlrpclib.ProtocolError, koji.GenericError))
@util.retry(wait_on=(xmlrpc.client.ProtocolError, koji.GenericError))
def login(self):
"""Authenticate to the hub."""
auth_type = self.koji_module.config.authtype
@ -145,7 +145,7 @@ class KojiWrapper(object):
cmd.append(arch)
if isinstance(command, list):
command = " ".join([shlex_quote(i) for i in command])
command = " ".join([shlex.quote(i) for i in command])
# HACK: remove rpmdb and yum cache
command = (
@ -153,7 +153,7 @@ class KojiWrapper(object):
)
if chown_paths:
paths = " ".join(shlex_quote(pth) for pth in chown_paths)
paths = " ".join(shlex.quote(pth) for pth in chown_paths)
command += " ; EXIT_CODE=$?"
# Make the files world readable
command += " ; chmod -R a+r %s" % paths
@ -359,7 +359,7 @@ class KojiWrapper(object):
for option, value in opts.items():
if isinstance(value, list):
value = ",".join(value)
if not isinstance(value, six.string_types):
if not isinstance(value, str):
# Python 3 configparser will reject non-string values.
value = str(value)
cfg_parser.set(section, option, value)
@ -765,11 +765,11 @@ class KojiWrapper(object):
return results
@util.retry(wait_on=(xmlrpclib.ProtocolError, koji.GenericError))
@util.retry(wait_on=(xmlrpc.client.ProtocolError, koji.GenericError))
def retrying_multicall_map(self, *args, **kwargs):
"""
Retrying version of multicall_map. This tries to retry the Koji call
in case of koji.GenericError or xmlrpclib.ProtocolError.
in case of koji.GenericError or xmlrpc.client.ProtocolError.
Please refer to koji_multicall_map for further specification of arguments.
"""

View File

@ -19,10 +19,9 @@ from __future__ import absolute_import
import os
import shutil
import glob
import six
import shlex
import threading
from six.moves import shlex_quote
from six.moves.urllib.request import urlretrieve
from urllib.request import urlretrieve
from fnmatch import fnmatch
import kobo.log
@ -285,8 +284,8 @@ class RpmScmWrapper(ScmBase):
run(
"cp -a %s %s/"
% (
shlex_quote(os.path.join(tmp_dir, scm_dir)),
shlex_quote(target_dir),
shlex.quote(os.path.join(tmp_dir, scm_dir)),
shlex.quote(target_dir),
)
)
@ -398,7 +397,7 @@ def get_file_from_scm(scm_dict, target_path, compose=None):
>>> get_file_from_scm(scm_dict, target_path)
['/tmp/path/share/variants.dtd']
"""
if isinstance(scm_dict, six.string_types):
if isinstance(scm_dict, str):
scm_type = "file"
scm_repo = None
scm_file = os.path.abspath(scm_dict)
@ -491,7 +490,7 @@ def get_dir_from_scm(scm_dict, target_path, compose=None):
>>> get_dir_from_scm(scm_dict, target_path)
['/tmp/path/share/variants.dtd', '/tmp/path/share/rawhide-fedora.ks', ...]
"""
if isinstance(scm_dict, six.string_types):
if isinstance(scm_dict, str):
scm_type = "file"
scm_repo = None
scm_dir = os.path.abspath(scm_dict)

View File

@ -15,8 +15,8 @@
from kobo import shortcuts
import os
import productmd
import shlex
import tempfile
from six.moves import shlex_quote
from pungi import util
from pungi.phases.buildinstall import tweak_configs
@ -24,7 +24,7 @@ from pungi.wrappers import iso
def sh(log, cmd, *args, **kwargs):
log.info("Running: %s", " ".join(shlex_quote(x) for x in cmd))
log.info("Running: %s", " ".join(shlex.quote(x) for x in cmd))
ret, out = shortcuts.run(cmd, *args, universal_newlines=True, **kwargs)
if out:
log.debug("%s", out)

View File

@ -61,7 +61,6 @@ setup(
"kobo",
"lxml",
"productmd>=1.23",
"six",
"dogpile.cache",
],
extras_require={':python_version=="2.7"': ["enum34", "lockfile"]},

View File

@ -8,8 +8,10 @@ import shutil
import tempfile
from collections import defaultdict
from unittest import mock
import six
try:
from unittest import mock
except ImportError:
import mock
from kobo.rpmlib import parse_nvr
import unittest
@ -303,7 +305,7 @@ def touch(path, content=None, mode=None):
os.makedirs(os.path.dirname(path))
except OSError:
pass
if not isinstance(content, six.binary_type):
if not isinstance(content, bytes):
content = content.encode()
with open(path, "wb") as f:
f.write(content)

View File

@ -1,22 +1,18 @@
from unittest import mock
import io
import unittest
import six
from pungi.scripts.pungi_koji import cli_main
class PungiKojiTestCase(unittest.TestCase):
@mock.patch("sys.argv", new=["prog", "--version"])
@mock.patch("sys.stderr", new_callable=six.StringIO)
@mock.patch("sys.stdout", new_callable=six.StringIO)
@mock.patch("sys.stderr", new_callable=io.StringIO)
@mock.patch("sys.stdout", new_callable=io.StringIO)
@mock.patch("pungi.scripts.pungi_koji.get_full_version", return_value="a-b-c.111")
def test_version(self, get_full_version, stdout, stderr):
with self.assertRaises(SystemExit) as cm:
cli_main()
self.assertEqual(cm.exception.code, 0)
# Python 2.7 prints the version to stderr, 3.4+ to stdout.
if six.PY3:
self.assertMultiLineEqual(stdout.getvalue(), "a-b-c.111\n")
else:
self.assertMultiLineEqual(stderr.getvalue(), "a-b-c.111\n")
self.assertMultiLineEqual(stdout.getvalue(), "a-b-c.111\n")

View File

@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
import unittest
from unittest import mock
import six
try:
from unittest import mock
except ImportError:
import mock
from copy import copy
from six.moves import StringIO
from io import StringIO
from ddt import ddt, data
import os
@ -117,8 +117,7 @@ class TestBuildinstallPhase(PungiTestCase):
# Server.x86_64, Client.amd64, Server.x86_64
pool = poolCls.return_value
self.assertEqual(3, len(pool.queue_put.mock_calls))
six.assertCountEqual(
self,
self.assertCountEqual(
[call[0][0][3] for call in pool.queue_put.call_args_list],
[
"rm -rf %s/work/amd64/buildinstall/Client && lorax ..." % self.topdir,
@ -128,8 +127,7 @@ class TestBuildinstallPhase(PungiTestCase):
)
# Obtained correct lorax commands.
six.assertCountEqual(
self,
self.assertCountEqual(
loraxCls.return_value.get_lorax_cmd.mock_calls,
[
mock.call(
@ -221,8 +219,7 @@ class TestBuildinstallPhase(PungiTestCase):
),
],
)
six.assertCountEqual(
self,
self.assertCountEqual(
get_volid.mock_calls,
[
mock.call(
@ -361,14 +358,12 @@ class TestBuildinstallPhase(PungiTestCase):
# Server.x86_64, Client.amd64, Server.x86_64
pool = poolCls.return_value
self.assertEqual(3, len(pool.queue_put.mock_calls))
six.assertCountEqual(
self,
self.assertCountEqual(
[call[0][0][3] for call in pool.queue_put.call_args_list],
expected_args,
)
six.assertCountEqual(
self,
self.assertCountEqual(
get_volid.mock_calls,
[
mock.call(
@ -520,8 +515,7 @@ class TestBuildinstallPhase(PungiTestCase):
# Server.x86_64, Client.amd64, Server.x86_64
pool = poolCls.return_value
self.assertEqual(3, len(pool.queue_put.mock_calls))
six.assertCountEqual(
self,
self.assertCountEqual(
[call[0][0][3] for call in pool.queue_put.call_args_list],
[
"rm -rf %s/work/amd64/buildinstall/Client && lorax ..." % self.topdir,
@ -531,8 +525,7 @@ class TestBuildinstallPhase(PungiTestCase):
)
# Obtained correct lorax commands.
six.assertCountEqual(
self,
self.assertCountEqual(
loraxCls.return_value.get_lorax_cmd.mock_calls,
[
mock.call(
@ -627,8 +620,7 @@ class TestBuildinstallPhase(PungiTestCase):
),
],
)
six.assertCountEqual(
self,
self.assertCountEqual(
get_volid.mock_calls,
[
mock.call(
@ -655,8 +647,7 @@ class TestBuildinstallPhase(PungiTestCase):
There should be one get_file call. This is because the configuration_file
option was used only once in the above configuration.
"""
six.assertCountEqual(
self,
self.assertCountEqual(
get_file.mock_calls,
[
mock.call(
@ -703,8 +694,7 @@ class TestBuildinstallPhase(PungiTestCase):
# Server.x86_64, Client.amd64, Server.x86_64
pool = poolCls.return_value
self.assertEqual(3, len(pool.queue_put.mock_calls))
six.assertCountEqual(
self,
self.assertCountEqual(
[call[0][0][3] for call in pool.queue_put.call_args_list],
[
"rm -rf %s/work/amd64/buildinstall/Client && lorax ..." % self.topdir,
@ -714,8 +704,7 @@ class TestBuildinstallPhase(PungiTestCase):
)
# Obtained correct lorax commands.
six.assertCountEqual(
self,
self.assertCountEqual(
loraxCls.return_value.get_lorax_cmd.mock_calls,
[
mock.call(
@ -804,8 +793,7 @@ class TestBuildinstallPhase(PungiTestCase):
),
],
)
six.assertCountEqual(
self,
self.assertCountEqual(
get_volid.mock_calls,
[
mock.call(
@ -862,8 +850,7 @@ class TestBuildinstallPhase(PungiTestCase):
# Server.x86_64, Client.amd64, Server.x86_64
pool = poolCls.return_value
self.assertEqual(3, len(pool.queue_put.mock_calls))
six.assertCountEqual(
self,
self.assertCountEqual(
[call[0][0][3] for call in pool.queue_put.call_args_list],
[
"rm -rf %s/amd64/Client && lorax ..." % buildinstall_topdir,
@ -873,8 +860,7 @@ class TestBuildinstallPhase(PungiTestCase):
)
# Obtained correct lorax commands.
six.assertCountEqual(
self,
self.assertCountEqual(
loraxCls.return_value.get_lorax_cmd.mock_calls,
[
mock.call(
@ -963,8 +949,7 @@ class TestBuildinstallPhase(PungiTestCase):
),
],
)
six.assertCountEqual(
self,
self.assertCountEqual(
get_volid.mock_calls,
[
mock.call(
@ -1023,8 +1008,7 @@ class TestBuildinstallPhase(PungiTestCase):
phase.run()
self.maxDiff = None
six.assertCountEqual(
self,
self.assertCountEqual(
loraxCls.return_value.get_lorax_cmd.mock_calls,
[
mock.call(
@ -1202,8 +1186,8 @@ class BuildinstallThreadTestCase(PungiTestCase):
self.topdir + "/logs/x86_64/buildinstall-Server-RPMs.x86_64.log"
) as f:
rpms = f.read().strip().split("\n")
six.assertCountEqual(self, rpms, ["bash", "zsh"])
six.assertCountEqual(self, self.pool.finished_tasks, [("Server", "x86_64")])
self.assertCountEqual(rpms, ["bash", "zsh"])
self.assertCountEqual(self.pool.finished_tasks, [("Server", "x86_64")])
self.assertEqual(
mock_tweak.call_args_list,
@ -1297,8 +1281,8 @@ class BuildinstallThreadTestCase(PungiTestCase):
self.topdir + "/logs/x86_64/buildinstall-Server-RPMs.x86_64.log"
) as f:
rpms = f.read().strip().split("\n")
six.assertCountEqual(self, rpms, ["bash", "zsh"])
six.assertCountEqual(self, self.pool.finished_tasks, [("Server", "x86_64")])
self.assertCountEqual(rpms, ["bash", "zsh"])
self.assertCountEqual(self.pool.finished_tasks, [("Server", "x86_64")])
self.assertEqual(
mock_tweak.call_args_list,
@ -1378,7 +1362,6 @@ class BuildinstallThreadTestCase(PungiTestCase):
)
self.assertEqual(self.pool.finished_tasks, set())
@unittest.skipUnless(six.PY3, "PY2 StringIO does not work with 'with' statement")
@mock.patch("pungi.wrappers.kojiwrapper.KojiWrapper")
@mock.patch("pungi.wrappers.kojiwrapper.get_buildroot_rpms")
@mock.patch("pungi.phases.buildinstall.run")
@ -1565,14 +1548,13 @@ class BuildinstallThreadTestCase(PungiTestCase):
self.topdir + "/logs/x86_64/buildinstall-Server-RPMs.x86_64.log"
) as f:
rpms = f.read().strip().split("\n")
six.assertCountEqual(self, rpms, ["bash", "zsh"])
six.assertCountEqual(self, self.pool.finished_tasks, [("Server", "x86_64")])
self.assertCountEqual(rpms, ["bash", "zsh"])
self.assertCountEqual(self.pool.finished_tasks, [("Server", "x86_64")])
buildinstall_topdir = os.path.join(
"/buildinstall_topdir", "buildinstall-" + os.path.basename(self.topdir)
)
six.assertCountEqual(
self,
self.assertCountEqual(
copy_all.mock_calls,
[
mock.call(

View File

@ -4,7 +4,7 @@ from unittest import mock
import unittest
import os
from six import StringIO
from io import StringIO
import kobo.conf

View File

@ -6,7 +6,6 @@ from unittest import mock
import json
import os
import shutil
import six
import tempfile
import unittest
@ -394,22 +393,17 @@ class ComposeTestCase(unittest.TestCase):
sorted(v.uid for v in compose.variants["Server"].variants.values()),
["Server-Gluster", "Server-ResilientStorage", "Server-optional"],
)
six.assertCountEqual(
self, compose.variants["Client"].arches, ["i386", "x86_64"]
)
self.assertCountEqual(compose.variants["Client"].arches, ["i386", "x86_64"])
self.assertEqual(compose.variants["Crashy"].arches, ["ppc64le"])
self.assertEqual(compose.variants["Live"].arches, ["x86_64"])
six.assertCountEqual(
self, compose.variants["Server"].arches, ["s390x", "x86_64"]
)
self.assertCountEqual(compose.variants["Server"].arches, ["s390x", "x86_64"])
self.assertEqual(
compose.variants["Server"].variants["Gluster"].arches, ["x86_64"]
)
self.assertEqual(
compose.variants["Server"].variants["ResilientStorage"].arches, ["x86_64"]
)
six.assertCountEqual(
self,
self.assertCountEqual(
compose.variants["Server"].variants["optional"].arches,
["s390x", "x86_64"],
)
@ -503,12 +497,8 @@ class ComposeTestCase(unittest.TestCase):
self.assertEqual(
sorted(v.uid for v in compose.variants.values()), ["Client", "Server"]
)
six.assertCountEqual(
self, compose.variants["Client"].arches, ["i386", "x86_64"]
)
six.assertCountEqual(
self, compose.variants["Server"].arches, ["s390x", "x86_64"]
)
self.assertCountEqual(compose.variants["Client"].arches, ["i386", "x86_64"])
self.assertCountEqual(compose.variants["Server"].arches, ["s390x", "x86_64"])
self.assertEqual(
compose.variants["Server"].variants["Gluster"].arches, ["x86_64"]
)
@ -559,8 +549,7 @@ class ComposeTestCase(unittest.TestCase):
["Client", "Server", "Server-optional"],
)
six.assertCountEqual(
self,
self.assertCountEqual(
logger.info.call_args_list,
[
mock.call("Excluding variant Live: filtered by configuration."),

View File

@ -2,8 +2,10 @@
import unittest
import six
from unittest import mock
try:
from unittest import mock
except ImportError:
import mock
from pungi import checks
from tests.helpers import load_config, PKGSET_REPOS
@ -12,7 +14,7 @@ from tests.helpers import load_config, PKGSET_REPOS
class ConfigTestCase(unittest.TestCase):
def assertValidation(self, cfg, errors=[], warnings=[]):
actual_errors, actual_warnings = checks.validate(cfg)
six.assertCountEqual(self, errors, actual_errors)
self.assertCountEqual(errors, actual_errors)
self.assertEqual(warnings, actual_warnings)
@ -263,8 +265,7 @@ class GatherConfigTestCase(ConfigTestCase):
pkgset_koji_tag="f27",
)
with mock.patch("six.PY2", new=False):
self.assertValidation(cfg, [])
self.assertValidation(cfg, [])
self.assertEqual(cfg["gather_backend"], "dnf")
def test_yum_backend_is_rejected_on_py3(self):
@ -274,11 +275,10 @@ class GatherConfigTestCase(ConfigTestCase):
gather_backend="yum",
)
with mock.patch("six.PY2", new=False):
self.assertValidation(
cfg,
["Failed validation in gather_backend: 'yum' is not one of ['dnf']"],
)
self.assertValidation(
cfg,
["Failed validation in gather_backend: 'yum' is not one of ['dnf']"],
)
class OSBSConfigTestCase(ConfigTestCase):
@ -437,9 +437,10 @@ class TestRegexValidation(ConfigTestCase):
def test_incorrect_regular_expression(self):
cfg = load_config(PKGSET_REPOS, multilib=[("^*$", {"*": []})])
msg = "Failed validation in multilib.0.0: incorrect regular expression: nothing to repeat" # noqa: E501
if six.PY3:
msg += " at position 1"
msg = (
"Failed validation in multilib.0.0: incorrect regular expression: "
"nothing to repeat at position 1"
)
self.assertValidation(cfg, [msg], [])

View File

@ -1,9 +1,11 @@
# -*- coding: utf-8 -*-
from unittest import mock
try:
from unittest import mock
except ImportError:
import mock
import io
import os
import six
from pungi.scripts.config_validate import cli_main
from tests import helpers
@ -16,8 +18,8 @@ SCHEMA_OVERRIDE = os.path.join(HERE, "data/dummy-override.json")
class ConfigValidateScriptTest(helpers.PungiTestCase):
@mock.patch("sys.argv", new=["pungi-config-validate", DUMMY_CONFIG])
@mock.patch("sys.stderr", new_callable=six.StringIO)
@mock.patch("sys.stdout", new_callable=six.StringIO)
@mock.patch("sys.stderr", new_callable=io.StringIO)
@mock.patch("sys.stdout", new_callable=io.StringIO)
def test_validate_dummy_config(self, stdout, stderr):
cli_main()
self.assertEqual("", stdout.getvalue())
@ -32,8 +34,8 @@ class ConfigValidateScriptTest(helpers.PungiTestCase):
SCHEMA_OVERRIDE,
],
)
@mock.patch("sys.stderr", new_callable=six.StringIO)
@mock.patch("sys.stdout", new_callable=six.StringIO)
@mock.patch("sys.stderr", new_callable=io.StringIO)
@mock.patch("sys.stdout", new_callable=io.StringIO)
@mock.patch("sys.exit")
def test_schema_override(self, exit, stdout, stderr):
cli_main()

View File

@ -2,9 +2,12 @@
import logging
from unittest import mock
import contextlib
import six
try:
from unittest import mock
except ImportError:
import mock
import productmd
import os
@ -45,8 +48,7 @@ class CreateisoPhaseTest(helpers.PungiTestCase):
self.assertEqual(len(pool.add.call_args_list), 0)
self.assertEqual(pool.queue_put.call_args_list, [])
six.assertCountEqual(
self,
self.assertCountEqual(
phase.logger.warning.call_args_list,
[
mock.call("No RPMs found for Everything.x86_64, skipping ISO"),
@ -193,8 +195,7 @@ class CreateisoPhaseTest(helpers.PungiTestCase):
phase.logger = mock.Mock()
phase.run()
six.assertCountEqual(
self,
self.assertCountEqual(
prepare_iso.call_args_list,
[
mock.call(
@ -215,8 +216,7 @@ class CreateisoPhaseTest(helpers.PungiTestCase):
),
],
)
six.assertCountEqual(
self,
self.assertCountEqual(
split_iso.call_args_list,
[
mock.call(
@ -237,8 +237,7 @@ class CreateisoPhaseTest(helpers.PungiTestCase):
)
self.assertEqual(len(pool.add.call_args_list), 2)
self.maxDiff = None
six.assertCountEqual(
self,
self.assertCountEqual(
[x[0][0] for x in write_script.call_args_list],
[
CreateIsoOpts(
@ -273,8 +272,7 @@ class CreateisoPhaseTest(helpers.PungiTestCase):
),
],
)
six.assertCountEqual(
self,
self.assertCountEqual(
pool.queue_put.call_args_list,
[
mock.call(

View File

@ -4,7 +4,7 @@ from unittest import mock
from parameterized import parameterized
import os
from six.moves import StringIO
from io import StringIO
from tests import helpers
from pungi import createiso

View File

@ -2,8 +2,6 @@
import unittest
import six
from pungi.wrappers.createrepo import CreaterepoWrapper
@ -13,8 +11,8 @@ class CreateRepoWrapperTest(unittest.TestCase):
cmd = repo.get_createrepo_cmd("/test/dir")
self.assertEqual(cmd[:2], ["createrepo_c", "/test/dir"])
six.assertCountEqual(
self, cmd[2:], ["--update", "--database", "--unique-md-filenames"]
self.assertCountEqual(
cmd[2:], ["--update", "--database", "--unique-md-filenames"]
)
def test_get_createrepo_c_cmd_full(self):
@ -50,8 +48,7 @@ class CreateRepoWrapperTest(unittest.TestCase):
self.maxDiff = None
self.assertEqual(cmd[:2], ["createrepo_c", "/test/dir"])
six.assertCountEqual(
self,
self.assertCountEqual(
cmd[2:],
[
"--baseurl=http://base.example.com",
@ -89,8 +86,7 @@ class CreateRepoWrapperTest(unittest.TestCase):
cmd = repo.get_createrepo_cmd("/test/dir")
self.assertEqual(cmd[:2], ["createrepo", "/test/dir"])
six.assertCountEqual(
self,
self.assertCountEqual(
cmd[2:],
["--update", "--database", "--unique-md-filenames", "--pretty"],
)
@ -126,8 +122,7 @@ class CreateRepoWrapperTest(unittest.TestCase):
self.maxDiff = None
self.assertEqual(cmd[:2], ["createrepo", "/test/dir"])
six.assertCountEqual(
self,
self.assertCountEqual(
cmd[2:],
[
"--baseurl=http://base.example.com",

View File

@ -4,8 +4,10 @@ import glob
import os
import unittest
from unittest import mock
import six
try:
from unittest import mock
except ImportError:
import mock
from pungi.module_util import Modulemd
from pungi.phases.createrepo import (
@ -71,8 +73,7 @@ class TestCreaterepoPhase(PungiTestCase):
everything = compose.variants["Everything"]
client = compose.variants["Client"]
self.assertEqual(len(pool.add.mock_calls), 5)
six.assertCountEqual(
self,
self.assertCountEqual(
pool.queue_put.mock_calls,
[
mock.call((compose, "x86_64", server, "rpm")),
@ -107,8 +108,7 @@ class TestCreaterepoPhase(PungiTestCase):
server = compose.variants["Server"]
everything = compose.variants["Everything"]
self.assertEqual(len(pool.add.mock_calls), 5)
six.assertCountEqual(
self,
self.assertCountEqual(
pool.queue_put.mock_calls,
[
mock.call((compose, "x86_64", server, "rpm")),
@ -159,8 +159,7 @@ def make_mocked_modifyrepo_cmd(tc, module_artifacts):
tc.assertEqual(len(module_streams), len(module_artifacts))
for ms in module_streams:
tc.assertIn(ms.get_stream_name(), module_artifacts)
six.assertCountEqual(
tc,
tc.assertCountEqual(
ms.get_rpm_artifacts(),
module_artifacts[ms.get_stream_name()],
)
@ -1356,7 +1355,7 @@ class TestGetProductIds(PungiTestCase):
"productid",
)
)
six.assertCountEqual(self, pids, expected)
self.assertCountEqual(pids, expected)
@mock.patch("pungi.phases.createrepo.get_dir_from_scm")
def test_not_configured(self, get_dir_from_scm):

View File

@ -5,8 +5,6 @@ import os
from productmd.extra_files import ExtraFiles
import six
from pungi.phases import extra_files
from tests import helpers
@ -31,8 +29,7 @@ class TestExtraFilePhase(helpers.PungiTestCase):
phase = extra_files.ExtraFilesPhase(compose, pkgset_phase)
phase.run()
six.assertCountEqual(
self,
self.assertCountEqual(
copy_extra_files.call_args_list,
[
mock.call(

View File

@ -1,9 +1,13 @@
# -*- coding: utf-8 -*-
from typing import AnyStr, List
from unittest import mock
import six
import logging
try:
from unittest import mock
except ImportError:
import mock
from typing import AnyStr, List
import os
from tests import helpers
@ -35,8 +39,7 @@ class ExtraIsosPhaseTest(helpers.PungiTestCase):
phase.run()
self.assertEqual(len(ThreadPool.return_value.add.call_args_list), 3)
six.assertCountEqual(
self,
self.assertCountEqual(
ThreadPool.return_value.queue_put.call_args_list,
[
mock.call((compose, cfg, compose.variants["Server"], "x86_64")),
@ -56,8 +59,7 @@ class ExtraIsosPhaseTest(helpers.PungiTestCase):
phase.run()
self.assertEqual(len(ThreadPool.return_value.add.call_args_list), 2)
six.assertCountEqual(
self,
self.assertCountEqual(
ThreadPool.return_value.queue_put.call_args_list,
[
mock.call((compose, cfg, compose.variants["Server"], "x86_64")),
@ -76,8 +78,7 @@ class ExtraIsosPhaseTest(helpers.PungiTestCase):
phase.run()
self.assertEqual(len(ThreadPool.return_value.add.call_args_list), 2)
six.assertCountEqual(
self,
self.assertCountEqual(
ThreadPool.return_value.queue_put.call_args_list,
[
mock.call((compose, cfg, compose.variants["Server"], "x86_64")),
@ -671,8 +672,7 @@ class GetIsoContentsTest(helpers.PungiTestCase):
"Server/repodata/repomd.xml": "/mnt/repodata/repomd.xml",
}
six.assertCountEqual(
self,
self.assertCountEqual(
ggp.call_args_list,
[
mock.call(
@ -753,8 +753,7 @@ class GetIsoContentsTest(helpers.PungiTestCase):
"Server/repodata/repomd.xml": "/mnt/repodata/repomd.xml",
}
six.assertCountEqual(
self,
self.assertCountEqual(
ggp.call_args_list,
[
mock.call(
@ -831,8 +830,7 @@ class GetIsoContentsTest(helpers.PungiTestCase):
"Server/repodata/repomd.xml": "/mnt/repodata/repomd.xml",
}
six.assertCountEqual(
self,
self.assertCountEqual(
ggp.call_args_list,
[
mock.call(
@ -934,8 +932,7 @@ class GetIsoContentsTest(helpers.PungiTestCase):
),
}
six.assertCountEqual(
self,
self.assertCountEqual(
ggp.call_args_list,
[
mock.call(

View File

@ -4,8 +4,6 @@ import unittest
import tempfile
from textwrap import dedent
import six
import os
from pungi.wrappers import fus
@ -133,8 +131,7 @@ class TestParseOutput(unittest.TestCase):
def test_separates_arch(self):
touch(self.file, "pkg-1.0-1.x86_64@repo-0\npkg-1.0-1.i686@repo-0\n")
packages, modules = fus.parse_output(self.file)
six.assertCountEqual(
self,
self.assertCountEqual(
packages,
[("pkg-1.0-1", "x86_64", frozenset()), ("pkg-1.0-1", "i686", frozenset())],
)

File diff suppressed because it is too large Load Diff

View File

@ -5,8 +5,6 @@ import copy
from unittest import mock
import os
import six
from pungi.phases.gather.methods import method_hybrid as hybrid
from pungi.phases.pkgset.common import MaterializedPackageSet as PkgSet
from tests import helpers
@ -210,7 +208,7 @@ class TestMethodHybrid(helpers.PungiTestCase):
]
expanded = m.expand_list(["foo*"])
six.assertCountEqual(self, [p.name for p in expanded], ["foo", "foo-en"])
self.assertCountEqual([p.name for p in expanded], ["foo", "foo-en"])
class MockModule(object):
@ -445,7 +443,7 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
cache_dir="/cache",
)
six.assertCountEqual(self, res[0], po.return_value[0])
self.assertCountEqual(res[0], po.return_value[0])
self.assertEqual(res[1], set())
self.assertEqual(po.call_args_list, [mock.call(self.logfile1)])
self.assertEqual(
@ -512,8 +510,7 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
cache_dir="/cache",
)
six.assertCountEqual(
self,
self.assertCountEqual(
res[0],
[
("pkg-1.0-1", "x86_64", frozenset()),
@ -585,7 +582,7 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
cache_dir="/cache",
)
six.assertCountEqual(self, res[0], final)
self.assertCountEqual(res[0], final)
self.assertEqual(res[1], set())
self.assertEqual(
po.call_args_list, [mock.call(self.logfile1), mock.call(self.logfile2)]
@ -675,8 +672,7 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
cache_dir="/cache",
)
six.assertCountEqual(
self,
self.assertCountEqual(
res[0],
[
("pkg-devel-1.0-1", "x86_64", frozenset()),
@ -796,8 +792,7 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
cache_dir="/cache",
)
six.assertCountEqual(
self,
self.assertCountEqual(
res[0],
[
("pkg-devel-1.0-1", "x86_64", frozenset()),

View File

@ -3,8 +3,6 @@
from unittest import mock
import os
import six
from pungi.phases.gather.methods import method_nodeps as nodeps
from tests import helpers
@ -21,8 +19,7 @@ class TestWritePungiConfig(helpers.PungiTestCase):
packages = nodeps.expand_groups(
self.compose, "x86_64", None, ["core", "text-internet"]
)
six.assertCountEqual(
self,
self.assertCountEqual(
packages,
[
("dummy-bash", "x86_64"),

View File

@ -8,8 +8,6 @@ from unittest import mock
import unittest
import six
from pungi.phases import gather
from pungi.phases.gather import _mk_pkg_map
from pungi.phases.pkgset.common import MaterializedPackageSet
@ -137,8 +135,7 @@ class TestGatherWrapper(helpers.PungiTestCase):
}
},
)
six.assertCountEqual(
self,
self.assertCountEqual(
write_packages.call_args_list,
[
mock.call(
@ -191,8 +188,7 @@ class TestGatherWrapper(helpers.PungiTestCase):
}
},
)
six.assertCountEqual(
self,
self.assertCountEqual(
write_packages.call_args_list,
[
mock.call(
@ -252,8 +248,7 @@ class TestGatherWrapper(helpers.PungiTestCase):
}
},
)
six.assertCountEqual(
self,
self.assertCountEqual(
write_packages.call_args_list,
[
mock.call(
@ -340,8 +335,7 @@ class TestGatherWrapper(helpers.PungiTestCase):
}
},
)
six.assertCountEqual(
self,
self.assertCountEqual(
write_packages.call_args_list,
[
mock.call(
@ -420,8 +414,7 @@ class TestGatherWrapper(helpers.PungiTestCase):
}
},
)
six.assertCountEqual(
self,
self.assertCountEqual(
write_packages.call_args_list,
[
mock.call(
@ -565,8 +558,7 @@ class TestGetSystemRelease(unittest.TestCase):
)
self.assertEqual(packages, set([("system-release-server", None)]))
six.assertCountEqual(
self,
self.assertCountEqual(
filter_packages,
set([("system-release-client", None), ("system-release", None)]),
)
@ -678,8 +670,7 @@ class TestWritePackages(helpers.PungiTestCase):
self.topdir, "work", "x86_64", "package_list", "Server.x86_64.rpm.conf"
)
) as f:
six.assertCountEqual(
self,
self.assertCountEqual(
f.read().strip().split("\n"),
[
"/build/foo-1.0-1.x86_64.rpm",
@ -693,8 +684,7 @@ class TestWritePackages(helpers.PungiTestCase):
self.topdir, "work", "x86_64", "package_list", "Server.x86_64.srpm.conf"
)
) as f:
six.assertCountEqual(
self,
self.assertCountEqual(
f.read().strip().split("\n"),
["/build/foo-1.0-1.src.rpm", "/build/bar-1.0-1.src.rpm"],
)
@ -809,8 +799,8 @@ class TestGetVariantPackages(helpers.PungiTestCase):
packages, groups, filter_packages = gather.get_variant_packages(
compose, "x86_64", compose.all_variants["Server-optional"], "comps"
)
six.assertCountEqual(self, packages, ["server-pkg", "addon-pkg", "opt-pkg"])
six.assertCountEqual(self, groups, ["server-group", "addon-group", "opt-group"])
self.assertCountEqual(packages, ["server-pkg", "addon-pkg", "opt-pkg"])
self.assertCountEqual(groups, ["server-group", "addon-group", "opt-group"])
self.assertEqual(filter_packages, set())
@mock.patch("pungi.phases.gather.get_gather_source")
@ -847,7 +837,7 @@ class TestGetVariantPackages(helpers.PungiTestCase):
packages, groups, filter_packages = gather.get_variant_packages(
compose, "x86_64", compose.all_variants["Server"], "comps"
)
six.assertCountEqual(self, packages, [("pkg", None), ("foo", "x86_64")])
self.assertCountEqual(packages, [("pkg", None), ("foo", "x86_64")])
self.assertEqual(groups, set())
self.assertEqual(filter_packages, set())
@ -1422,8 +1412,7 @@ class TestGetPrepopulate(helpers.PungiTestCase):
"prepopulate.json",
os.path.join(self.topdir, "work", "global", "prepopulate.json"),
)
six.assertCountEqual(
self,
self.assertCountEqual(
gather.get_prepopulate_packages(
self.compose, "x86_64", self.compose.variants["Server"]
),
@ -1435,8 +1424,7 @@ class TestGetPrepopulate(helpers.PungiTestCase):
"prepopulate.json",
os.path.join(self.topdir, "work", "global", "prepopulate.json"),
)
six.assertCountEqual(
self,
self.assertCountEqual(
gather.get_prepopulate_packages(self.compose, "x86_64", None),
["foo-common.noarch", "foo.i686", "foo.x86_64", "bar.x86_64"],
)
@ -1446,8 +1434,7 @@ class TestGetPrepopulate(helpers.PungiTestCase):
"prepopulate.json",
os.path.join(self.topdir, "work", "global", "prepopulate.json"),
)
six.assertCountEqual(
self,
self.assertCountEqual(
gather.get_prepopulate_packages(
self.compose, "x86_64", None, include_arch=False
),
@ -1483,8 +1470,7 @@ class TestGatherPhase(helpers.PungiTestCase):
gather_wrapper.call_args_list,
[mock.call(compose, pkgset_phase.package_sets, pkgset_phase.path_prefix)],
)
six.assertCountEqual(
self,
self.assertCountEqual(
link_files.call_args_list,
[
_mk_link_call("x86_64", "Server"),
@ -1582,7 +1568,7 @@ class TestGetPackagesToGather(helpers.PungiTestCase):
packages, groups = gather.get_packages_to_gather(self.compose)
six.assertCountEqual(self, packages, ["foo", "foo2.x86_64", "pkg"])
self.assertCountEqual(packages, ["foo", "foo2.x86_64", "pkg"])
self.assertEqual(groups, ["core"])
@mock.patch("pungi.phases.gather.get_gather_source")
@ -1595,7 +1581,7 @@ class TestGetPackagesToGather(helpers.PungiTestCase):
self.compose, include_arch=False
)
six.assertCountEqual(self, packages, ["foo", "foo2", "pkg"])
self.assertCountEqual(packages, ["foo", "foo2", "pkg"])
self.assertEqual(groups, ["core"])
@mock.patch("pungi.phases.gather.get_gather_source")
@ -1608,8 +1594,7 @@ class TestGetPackagesToGather(helpers.PungiTestCase):
self.compose, include_prepopulated=True
)
six.assertCountEqual(
self,
self.assertCountEqual(
packages,
[
"foo",
@ -1633,9 +1618,7 @@ class TestGetPackagesToGather(helpers.PungiTestCase):
self.compose, include_prepopulated=True, include_arch=False
)
six.assertCountEqual(
self, packages, ["foo", "pkg", "foo-common", "foo2", "bar"]
)
self.assertCountEqual(packages, ["foo", "pkg", "foo-common", "foo2", "bar"])
self.assertEqual(groups, ["core"])
@mock.patch("pungi.phases.gather.get_gather_source")
@ -1646,7 +1629,7 @@ class TestGetPackagesToGather(helpers.PungiTestCase):
packages, groups = gather.get_packages_to_gather(self.compose, "x86_64")
six.assertCountEqual(self, packages, ["foo", "pkg", "foo2.x86_64"])
self.assertCountEqual(packages, ["foo", "pkg", "foo2.x86_64"])
self.assertEqual(groups, ["core"])
@ -1765,8 +1748,7 @@ class TestMakeLookasideRepo(helpers.PungiTestCase):
def assertCorrect(self, repopath, path_prefix, MockCR, mock_run):
with open(self.pkglist) as f:
packages = f.read().splitlines()
six.assertCountEqual(
self,
self.assertCountEqual(
packages,
[
"pkg/pkg-1.0-1.x86_64.rpm",

View File

@ -2,8 +2,10 @@
import unittest
from unittest import mock
import six
try:
from unittest import mock
except ImportError:
import mock
from pungi.phases.gather.sources.source_module import GatherSourceModule
from tests import helpers
@ -51,8 +53,7 @@ class TestGatherSourceModule(helpers.PungiTestCase):
source = GatherSourceModule(self.compose)
packages, groups = source("x86_64", self.compose.variants["Server"])
six.assertCountEqual(
self,
self.assertCountEqual(
[(rpm[0].nevra, rpm[1]) for rpm in packages],
[("pkg-0:1.0.0-1.x86_64", None), ("pkg-0:1.0.0-1.i686", None)],
)

View File

@ -2,8 +2,6 @@
from unittest import mock
import six
import os
from pungi.phases.image_build import ImageBuildPhase, CreateImageBuildThread
@ -99,8 +97,7 @@ class TestImageBuildPhase(PungiTestCase):
"link_type": "hardlink-or-copy",
"scratch": False,
}
six.assertCountEqual(
self,
self.assertCountEqual(
phase.pool.queue_put.mock_calls,
[
mock.call((compose, client_args, phase.buildinstall_phase)),
@ -882,8 +879,7 @@ class TestCreateImageBuildThread(PungiTestCase):
],
)
six.assertCountEqual(
self,
self.assertCountEqual(
linker.mock_calls,
[
mock.call.link(

View File

@ -8,8 +8,6 @@ try:
except ImportError:
import mock
import six
import os
from pungi.module_util import Modulemd
@ -56,13 +54,11 @@ class TestInitPhase(PungiTestCase):
self.assertEqual(write_global.mock_calls, [mock.call(compose)])
self.assertEqual(write_prepopulate.mock_calls, [mock.call(compose)])
six.assertCountEqual(
self,
self.assertCountEqual(
write_arch.mock_calls,
[mock.call(compose, "x86_64"), mock.call(compose, "amd64")],
)
six.assertCountEqual(
self,
self.assertCountEqual(
create_comps.mock_calls,
[
mock.call(compose, "x86_64", None),
@ -75,8 +71,7 @@ class TestInitPhase(PungiTestCase):
mock.call(compose, "x86_64", compose.all_variants["Server-optional"]),
],
)
six.assertCountEqual(
self,
self.assertCountEqual(
write_variant.mock_calls,
[
mock.call(compose, "x86_64", compose.variants["Server"]),
@ -117,13 +112,11 @@ class TestInitPhase(PungiTestCase):
validate_comps.call_args_list, [mock.call(write_global.return_value)]
)
self.assertEqual(write_prepopulate.mock_calls, [mock.call(compose)])
six.assertCountEqual(
self,
self.assertCountEqual(
write_arch.mock_calls,
[mock.call(compose, "x86_64"), mock.call(compose, "amd64")],
)
six.assertCountEqual(
self,
self.assertCountEqual(
create_comps.mock_calls,
[
mock.call(compose, "x86_64", None),
@ -135,8 +128,7 @@ class TestInitPhase(PungiTestCase):
mock.call(compose, "amd64", compose.variants["Everything"]),
],
)
six.assertCountEqual(
self,
self.assertCountEqual(
write_variant.mock_calls,
[
mock.call(compose, "x86_64", compose.variants["Server"]),

View File

@ -3,7 +3,6 @@
import itertools
from unittest import mock
import os
import six
import unittest
from pungi.wrappers import iso
@ -41,7 +40,7 @@ def fake_listdir(pattern, result=None, exc=None):
# The point of this is to avoid issues on Python 2, where apparently
# isdir() is using listdir(), so the mocking is breaking it.
def worker(path):
if isinstance(path, six.string_types) and pattern in path:
if isinstance(path, str) and pattern in path:
if exc:
raise exc
return result

View File

@ -9,8 +9,6 @@ import tempfile
import os
import shutil
import six
from pungi.wrappers.kojiwrapper import KojiWrapper, get_buildroot_rpms
from .helpers import FIXTURE_DIR
@ -94,13 +92,12 @@ class KojiWrapperTest(KojiWrapperBaseTestCase):
)
self.assertEqual(cmd[:3], ["koji", "--profile=custom-koji", "image-build"])
six.assertCountEqual(self, cmd[3:], ["--config=" + self.tmpfile, "--wait"])
self.assertCountEqual(cmd[3:], ["--config=" + self.tmpfile, "--wait"])
with open(self.tmpfile, "r") as f:
lines = f.read().strip().split("\n")
self.assertEqual(lines[0], "[image-build]")
six.assertCountEqual(
self,
self.assertCountEqual(
lines[1:],
[
"name = test-name",
@ -287,10 +284,9 @@ class KojiWrapperTest(KojiWrapperBaseTestCase):
),
)
result = self.koji.get_image_paths(12387273)
six.assertCountEqual(self, result.keys(), ["i386", "x86_64"])
self.assertCountEqual(result.keys(), ["i386", "x86_64"])
self.maxDiff = None
six.assertCountEqual(
self,
self.assertCountEqual(
result["i386"],
[
"/koji/task/12387276/tdl-i386.xml",
@ -302,8 +298,7 @@ class KojiWrapperTest(KojiWrapperBaseTestCase):
"/koji/task/12387276/Fedora-Cloud-Base-23-20160103.i386.raw.xz",
],
)
six.assertCountEqual(
self,
self.assertCountEqual(
result["x86_64"],
[
"/koji/task/12387277/tdl-x86_64.xml",
@ -340,8 +335,8 @@ class KojiWrapperTest(KojiWrapperBaseTestCase):
result = self.koji.get_image_paths(25643870, callback=failed_callback)
six.assertCountEqual(self, result.keys(), ["aarch64", "armhfp", "x86_64"])
six.assertCountEqual(self, failed, ["ppc64le", "s390x"])
self.assertCountEqual(result.keys(), ["aarch64", "armhfp", "x86_64"])
self.assertCountEqual(failed, ["ppc64le", "s390x"])
def test_multicall_map(self):
self.koji.koji_proxy = mock.Mock()
@ -354,8 +349,7 @@ class KojiWrapperTest(KojiWrapperBaseTestCase):
[{"x": 1}, {"x": 2}],
)
six.assertCountEqual(
self,
self.assertCountEqual(
self.koji.koji_proxy.getBuild.mock_calls,
[mock.call("foo", x=1), mock.call("bar", x=2)],
)
@ -419,8 +413,7 @@ class LiveMediaTestCase(KojiWrapperBaseTestCase):
"--install-tree=/mnt/os",
],
)
six.assertCountEqual(
self,
self.assertCountEqual(
cmd[9:],
[
"--repo=repo-1",
@ -448,7 +441,7 @@ class RunrootKojiWrapperTest(KojiWrapperBaseTestCase):
self.assertEqual(
cmd[-1], "rm -f /var/lib/rpm/__db*; rm -rf /var/cache/yum/*; set -x; date"
)
six.assertCountEqual(self, cmd[5:-3], [])
self.assertCountEqual(cmd[5:-3], [])
def test_get_cmd_full(self):
cmd = self.koji.get_runroot_cmd(
@ -469,8 +462,7 @@ class RunrootKojiWrapperTest(KojiWrapperBaseTestCase):
cmd[-1],
"rm -f /var/lib/rpm/__db*; rm -rf /var/cache/yum/*; set -x; /bin/echo '&'",
)
six.assertCountEqual(
self,
self.assertCountEqual(
cmd[4:-3],
[
"--channel-override=chan",
@ -505,8 +497,7 @@ class RunrootKojiWrapperTest(KojiWrapperBaseTestCase):
cmd[-1],
"rm -f /var/lib/rpm/__db*; rm -rf /var/cache/yum/*; set -x; /bin/echo '&' ; EXIT_CODE=$? ; chmod -R a+r '/output dir' /foo ; chown -R 1010 '/output dir' /foo ; exit $EXIT_CODE", # noqa: E501
)
six.assertCountEqual(
self,
self.assertCountEqual(
cmd[4:-3],
[
"--channel-override=chan",
@ -641,8 +632,7 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
result = self.koji.run_blocking_cmd("cmd")
self.assertDictEqual(result, {"retcode": 0, "output": output, "task_id": 1234})
six.assertCountEqual(
self,
self.assertCountEqual(
run.mock_calls,
[
mock.call(
@ -668,8 +658,7 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
result = self.koji.run_blocking_cmd("cmd")
self.assertDictEqual(result, {"retcode": 0, "output": output, "task_id": 1234})
six.assertCountEqual(
self,
self.assertCountEqual(
run.mock_calls,
[
mock.call(
@ -696,8 +685,7 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
result = self.koji.run_blocking_cmd("cmd", log_file="logfile")
self.assertDictEqual(result, {"retcode": 0, "output": output, "task_id": 1234})
six.assertCountEqual(
self,
self.assertCountEqual(
run.mock_calls,
[
mock.call(
@ -720,8 +708,7 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
result = self.koji.run_blocking_cmd("cmd")
self.assertDictEqual(result, {"retcode": 1, "output": output, "task_id": 1234})
six.assertCountEqual(
self,
self.assertCountEqual(
run.mock_calls,
[
mock.call(
@ -744,8 +731,7 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
with self.assertRaises(RuntimeError) as ctx:
self.koji.run_blocking_cmd("cmd")
six.assertCountEqual(
self,
self.assertCountEqual(
run.mock_calls,
[
mock.call(
@ -1113,8 +1099,7 @@ class TestGetBuildrootRPMs(unittest.TestCase):
],
)
six.assertCountEqual(
self,
self.assertCountEqual(
rpms,
[
"python3-kickstart-2.25-2.fc24.noarch",
@ -1131,8 +1116,7 @@ class TestGetBuildrootRPMs(unittest.TestCase):
rpms = get_buildroot_rpms(compose, None)
six.assertCountEqual(
self,
self.assertCountEqual(
rpms,
[
"cjkuni-uming-fonts-0.2.20080216.1-56.fc23.noarch",

View File

@ -4,8 +4,6 @@ from unittest import mock
import os
import six
from pungi.phases.livemedia_phase import LiveMediaPhase, LiveMediaThread
from tests.helpers import DummyCompose, PungiTestCase, boom
@ -579,8 +577,7 @@ class TestLiveMediaThread(PungiTestCase):
self.assertTrue(os.path.isdir(self.topdir + "/compose/Server/x86_64/iso"))
self.assertTrue(os.path.isdir(self.topdir + "/compose/Server/amd64/iso"))
link = Linker.return_value.link
six.assertCountEqual(
self,
self.assertCountEqual(
link.mock_calls,
[
mock.call(

View File

@ -2,8 +2,6 @@
import unittest
import six
from pungi.wrappers.lorax import LoraxWrapper
@ -17,8 +15,7 @@ class LoraxWrapperTest(unittest.TestCase):
)
self.assertEqual(cmd[0], "lorax")
six.assertCountEqual(
self,
self.assertCountEqual(
cmd[1:],
[
"--product=product",
@ -56,8 +53,7 @@ class LoraxWrapperTest(unittest.TestCase):
)
self.assertEqual(cmd[0], "lorax")
six.assertCountEqual(
self,
self.assertCountEqual(
cmd[1:],
[
"--product=product",

View File

@ -1,8 +1,6 @@
from unittest import mock
import os
import six
from tests import helpers
from pungi import metadata
@ -131,8 +129,7 @@ class MediaRepoTestCase(helpers.PungiTestCase):
with open(self.path) as f:
lines = f.read().strip().split("\n")
self.assertEqual(lines[0], "[InstallMedia]")
six.assertCountEqual(
self,
self.assertCountEqual(
lines[1:],
[
"name=Test 1.0",
@ -190,8 +187,7 @@ class TestPopulateExtraFiles(helpers.PungiTestCase):
self.maxDiff = None
six.assertCountEqual(
self,
self.assertCountEqual(
self.metadata.mock_calls,
[
mock.call.add("Server", "x86_64", "Server/x86_64/os/foo", 3, FOO_MD5),
@ -210,8 +206,7 @@ class TestPopulateExtraFiles(helpers.PungiTestCase):
self.metadata, self.variant, "x86_64", self.topdir, ["foo", "bar"], ["md5"]
)
six.assertCountEqual(
self,
self.assertCountEqual(
self.metadata.mock_calls,
[
mock.call.add("Server", "x86_64", "foo", 3, FOO_MD5),

View File

@ -3,12 +3,12 @@
from unittest import mock
import os
import shlex
from kobo.shortcuts import force_list
from tests import helpers
from pungi.phases import ostree_installer as ostree
from six.moves import shlex_quote
LOG_PATH = "logs/x86_64/Everything/ostree_installer-1"
@ -144,7 +144,7 @@ class OstreeThreadTest(helpers.PungiTestCase):
]
for s in force_list(sources):
lorax_cmd.append(shlex_quote("--source=%s" % s))
lorax_cmd.append(shlex.quote("--source=%s" % s))
lorax_cmd.append("--variant=Everything")
lorax_cmd.append("--nomacboot")

View File

@ -4,8 +4,10 @@
import json
import os
from unittest import mock
import six
try:
from unittest import mock
except ImportError:
import mock
import yaml
from tests import helpers
@ -50,8 +52,7 @@ class OstreeTreeScriptTest(helpers.PungiTestCase):
)
def assertCorrectCall(self, mock_run, extra_calls=[], extra_args=[]):
six.assertCountEqual(
self,
self.assertCountEqual(
mock_run.call_args_list,
[
mock.call(
@ -393,8 +394,7 @@ class OstreeInstallerScriptTest(helpers.PungiTestCase):
args.append("--add-arch-template-var=ostree_repo=http://www.example.com/ostree")
ostree.main(args)
self.maxDiff = None
six.assertCountEqual(
self,
self.assertCountEqual(
run.mock_calls,
[
mock.call(
@ -457,8 +457,7 @@ class OstreeInstallerScriptTest(helpers.PungiTestCase):
args.append("--extra-config=%s" % extra_config_file)
ostree.main(args)
self.maxDiff = None
six.assertCountEqual(
self,
self.assertCountEqual(
run.mock_calls,
[
mock.call(

View File

@ -2,8 +2,10 @@
import os
from unittest import mock
import six
try:
from unittest import mock
except ImportError:
import mock
from pungi.module_util import Modulemd
from pungi.phases.pkgset import common
@ -65,9 +67,7 @@ class TestMaterializedPkgsetCreate(helpers.PungiTestCase):
self.compose, self.pkgset, self.prefix
)
six.assertCountEqual(
self, result.package_sets.keys(), ["global", "amd64", "x86_64"]
)
self.assertCountEqual(result.package_sets.keys(), ["global", "amd64", "x86_64"])
self.assertEqual(result["global"], self.pkgset)
self.assertEqual(result["x86_64"], self.subsets["x86_64"])
self.assertEqual(result["amd64"], self.subsets["amd64"])

View File

@ -3,7 +3,6 @@
import ddt
from unittest import mock
import os
import six
import unittest
import json
@ -127,7 +126,7 @@ class PkgsetCompareMixin(object):
for k, v1 in expected.items():
self.assertIn(k, actual)
v2 = actual.pop(k)
six.assertCountEqual(self, v1, v2)
self.assertCountEqual(v1, v2)
self.assertEqual({}, actual)
@ -178,7 +177,7 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase):
for k, v1 in expected.items():
self.assertIn(k, actual)
v2 = actual.pop(k)
six.assertCountEqual(self, v1, v2)
self.assertCountEqual(v1, v2)
self.assertEqual({}, actual, msg="Some architectures were missing")
@ddt.data(
@ -1360,6 +1359,6 @@ class TestSaveFileList(unittest.TestCase):
with open(self.tmpfile) as f:
rpms = f.read().strip().split("\n")
six.assertCountEqual(
self, rpms, ["pungi@4.1.3@3.fc25@noarch", "pungi@4.1.3@3.fc25@src"]
self.assertCountEqual(
rpms, ["pungi@4.1.3@3.fc25@noarch", "pungi@4.1.3@3.fc25@src"]
)

View File

@ -8,7 +8,6 @@ except ImportError:
import mock
import os
import re
import six
import unittest
from ddt import ddt, data, unpack
from typing import AnyStr, List, Set, Dict, Tuple
@ -61,8 +60,8 @@ class TestGetKojiEvent(helpers.PungiTestCase):
event = source_koji.get_koji_event_info(self.compose, koji_wrapper)
self.assertEqual(event, EVENT_INFO)
six.assertCountEqual(
self, koji_wrapper.mock_calls, [mock.call.koji_proxy.getEvent(123456)]
self.assertCountEqual(
koji_wrapper.mock_calls, [mock.call.koji_proxy.getEvent(123456)]
)
with open(self.event_file) as f:
self.assertEqual(json.load(f), EVENT_INFO)
@ -76,8 +75,8 @@ class TestGetKojiEvent(helpers.PungiTestCase):
event = source_koji.get_koji_event_info(self.compose, koji_wrapper)
self.assertEqual(event, EVENT_INFO)
six.assertCountEqual(
self, koji_wrapper.mock_calls, [mock.call.koji_proxy.getLastEvent()]
self.assertCountEqual(
koji_wrapper.mock_calls, [mock.call.koji_proxy.getLastEvent()]
)
with open(self.event_file) as f:
self.assertEqual(json.load(f), EVENT_INFO)
@ -150,15 +149,11 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase):
self.assertEqual(len(pkgsets), 2)
init_calls = KojiPackageSet.call_args_list
six.assertCountEqual(
self, [call[0][0] for call in init_calls], ["f25", "f25-extra"]
)
six.assertCountEqual(
self, [call[0][1] for call in init_calls], [self.koji_wrapper] * 2
)
six.assertCountEqual(
self, [call[0][2] for call in init_calls], [["foo", "bar"]] * 2
self.assertCountEqual([call[0][0] for call in init_calls], ["f25", "f25-extra"])
self.assertCountEqual(
[call[0][1] for call in init_calls], [self.koji_wrapper] * 2
)
self.assertCountEqual([call[0][2] for call in init_calls], [["foo", "bar"]] * 2)
pkgsets[0].assert_has_calls(
[
@ -196,7 +191,7 @@ class TestPopulateGlobalPkgset(helpers.PungiTestCase):
self.compose, self.koji_wrapper, 123456
)
self.assertEqual(len(pkgsets), 1)
six.assertCountEqual(self, pkgsets[0].packages, ["pkg", "foo"])
self.assertCountEqual(pkgsets[0].packages, ["pkg", "foo"])
class TestGetPackageSetFromKoji(helpers.PungiTestCase):
@ -214,8 +209,8 @@ class TestGetPackageSetFromKoji(helpers.PungiTestCase):
def test_get_package_sets(self, pgp):
pkgsets = source_koji.get_pkgset_from_koji(self.compose, self.koji_wrapper)
six.assertCountEqual(
self, self.koji_wrapper.koji_proxy.mock_calls, [mock.call.getLastEvent()]
self.assertCountEqual(
self.koji_wrapper.koji_proxy.mock_calls, [mock.call.getLastEvent()]
)
self.assertEqual(pkgsets, pgp.return_value)
@ -498,12 +493,12 @@ class TestCorrectNVR(helpers.PungiTestCase):
def test_nv(self):
module_info = source_koji.variant_dict_from_str(self.compose, self.nv)
expectedKeys = ["stream", "name"]
six.assertCountEqual(self, module_info.keys(), expectedKeys)
self.assertCountEqual(module_info.keys(), expectedKeys)
def test_nvr(self):
module_info = source_koji.variant_dict_from_str(self.compose, self.nvr)
expectedKeys = ["stream", "name", "version"]
six.assertCountEqual(self, module_info.keys(), expectedKeys)
self.assertCountEqual(module_info.keys(), expectedKeys)
def test_correct_release(self):
module_info = source_koji.variant_dict_from_str(self.compose, self.nvr)
@ -580,7 +575,7 @@ class TestFilterInherited(unittest.TestCase):
result = source_koji.filter_inherited(koji_proxy, event, module_builds, top_tag)
six.assertCountEqual(self, result, [m1])
self.assertCountEqual(result, [m1])
self.assertEqual(
koji_proxy.mock_calls,
[mock.call.getFullInheritance("top-tag", event=123456)],
@ -601,7 +596,7 @@ class TestFilterInherited(unittest.TestCase):
result = source_koji.filter_inherited(koji_proxy, event, module_builds, top_tag)
six.assertCountEqual(self, result, [m3])
self.assertCountEqual(result, [m3])
self.assertEqual(
koji_proxy.mock_calls,
[mock.call.getFullInheritance("top-tag", event=123456)],
@ -621,7 +616,7 @@ class TestFilterInherited(unittest.TestCase):
result = source_koji.filter_inherited(koji_proxy, event, module_builds, top_tag)
six.assertCountEqual(self, result, [m])
self.assertCountEqual(result, [m])
self.assertEqual(
koji_proxy.mock_calls,
[mock.call.getFullInheritance("top-tag", event=123456)],
@ -662,7 +657,7 @@ class TestFilterByWhitelist(unittest.TestCase):
compose, module_builds, input_modules, expected
)
six.assertCountEqual(self, result, [module_builds[0], module_builds[1]])
self.assertCountEqual(result, [module_builds[0], module_builds[1]])
self.assertEqual(expected, set())
def test_filter_by_NSV(self):
@ -714,7 +709,7 @@ class TestFilterByWhitelist(unittest.TestCase):
compose, module_builds, input_modules, expected
)
six.assertCountEqual(self, result, module_builds)
self.assertCountEqual(result, module_builds)
self.assertEqual(expected, set())

View File

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from unittest import mock
import six
import pungi.phases.repoclosure as repoclosure_phase
from tests.helpers import DummyCompose, PungiTestCase, mk_boom
@ -35,8 +34,7 @@ class TestRepoclosure(PungiTestCase):
compose = DummyCompose(self.topdir, {"repoclosure_backend": "dnf"})
repoclosure_phase.run_repoclosure(compose)
six.assertCountEqual(
self,
self.assertCountEqual(
mock_grc.call_args_list,
[
mock.call(
@ -89,8 +87,7 @@ class TestRepoclosure(PungiTestCase):
repoclosure_phase.run_repoclosure(compose)
self.assertEqual(mock_grc.call_args_list, [])
six.assertCountEqual(
self,
self.assertCountEqual(
effl.call_args_list,
[
mock.call([f], _log("amd64", "Everything")),
@ -129,8 +126,7 @@ class TestRepoclosure(PungiTestCase):
)
repoclosure_phase.run_repoclosure(compose)
six.assertCountEqual(
self,
self.assertCountEqual(
mock_grc.call_args_list,
[
mock.call(

View File

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
import os
import six
from pungi.wrappers import repoclosure as rc
@ -26,8 +25,7 @@ class RepoclosureWrapperTestCase(helpers.BaseTestCase):
backend="dnf", arch="x86_64", repos=repos, lookaside=lookaside
)
self.assertEqual(cmd[:2], ["dnf", "repoclosure"])
six.assertCountEqual(
self,
self.assertCountEqual(
cmd[2:],
[
"--arch=x86_64",
@ -51,8 +49,7 @@ class RepoclosureWrapperTestCase(helpers.BaseTestCase):
lookaside=lookaside,
)
self.assertEqual(cmd[:2], ["dnf", "repoclosure"])
six.assertCountEqual(
self,
self.assertCountEqual(
cmd[2:],
[
"--arch=x86_64",

View File

@ -10,8 +10,6 @@ import unittest
import http.server
import threading
import six
from parameterized import parameterized
from pungi.wrappers import scm
@ -28,7 +26,7 @@ class SCMBaseTest(unittest.TestCase):
def assertStructure(self, returned, expected):
# Check we returned the correct files
six.assertCountEqual(self, returned, expected)
self.assertCountEqual(returned, expected)
# Each file must exist
for f in expected:
@ -40,7 +38,7 @@ class SCMBaseTest(unittest.TestCase):
for f in files:
p = os.path.relpath(os.path.join(root, f), self.destdir)
found.append(p)
six.assertCountEqual(self, expected, found)
self.assertCountEqual(expected, found)
class FileSCMTestCase(SCMBaseTest):
@ -598,7 +596,7 @@ class RpmSCMTestCase(SCMBaseTest):
)
self.assertStructure(retval, ["some-file-1.txt", "some-file-2.txt"])
six.assertCountEqual(self, self.exploded, self.rpms)
self.assertCountEqual(self.exploded, self.rpms)
@mock.patch("pungi.wrappers.scm.explode_rpm_package")
def test_get_files_from_glob_rpms(self, explode):
@ -622,7 +620,7 @@ class RpmSCMTestCase(SCMBaseTest):
"some-file-4.txt",
],
)
six.assertCountEqual(self, self.exploded, self.numbered)
self.assertCountEqual(self.exploded, self.numbered)
@mock.patch("pungi.wrappers.scm.explode_rpm_package")
def test_get_dir_from_two_rpms(self, explode):
@ -633,7 +631,7 @@ class RpmSCMTestCase(SCMBaseTest):
)
self.assertStructure(retval, ["common/foo-1.txt", "common/foo-2.txt"])
six.assertCountEqual(self, self.exploded, self.rpms)
self.assertCountEqual(self.exploded, self.rpms)
@mock.patch("pungi.wrappers.scm.explode_rpm_package")
def test_get_dir_from_glob_rpms(self, explode):
@ -651,7 +649,7 @@ class RpmSCMTestCase(SCMBaseTest):
self.assertStructure(
retval, ["foo-1.txt", "foo-2.txt", "foo-3.txt", "foo-4.txt"]
)
six.assertCountEqual(self, self.exploded, self.numbered)
self.assertCountEqual(self.exploded, self.numbered)
class CvsSCMTestCase(SCMBaseTest):

View File

@ -3,8 +3,7 @@
from unittest import mock
import os
import shutil
import six
from six.moves.configparser import ConfigParser
from configparser import ConfigParser
from tests.helpers import PungiTestCase, FIXTURE_DIR, touch, mk_boom
from pungi_utils import unified_isos
@ -185,8 +184,7 @@ class TestLinkToTemp(PungiTestCase):
def test_link_to_temp(self):
self.isos.link_to_temp()
six.assertCountEqual(
self,
self.assertCountEqual(
self.isos.treeinfo.keys(),
[
"i386",
@ -202,8 +200,7 @@ class TestLinkToTemp(PungiTestCase):
self.assertEqual(self.isos.productid, get_productid_mapping(self.compose_path))
self.assertEqual(self.isos.repos, get_repos_mapping(self.isos.temp_dir))
six.assertCountEqual(
self,
self.assertCountEqual(
self.isos.linker.link.call_args_list,
[
self._linkCall(
@ -239,8 +236,7 @@ class TestLinkToTemp(PungiTestCase):
with mock.patch("sys.stderr"):
self.isos.link_to_temp()
six.assertCountEqual(
self,
self.assertCountEqual(
self.isos.treeinfo.keys(),
["s390x", "src", "x86_64", "debug-s390x", "debug-x86_64"],
)
@ -257,8 +253,7 @@ class TestLinkToTemp(PungiTestCase):
self.maxDiff = None
six.assertCountEqual(
self,
self.assertCountEqual(
self.isos.linker.link.call_args_list,
[
self._linkCall(
@ -290,8 +285,7 @@ class TestLinkToTemp(PungiTestCase):
self.isos.link_to_temp()
six.assertCountEqual(
self,
self.assertCountEqual(
self.isos.treeinfo.keys(),
[
"i386",
@ -307,8 +301,7 @@ class TestLinkToTemp(PungiTestCase):
self.assertEqual(self.isos.productid, get_productid_mapping(self.compose_path))
self.assertEqual(self.isos.repos, get_repos_mapping(self.isos.temp_dir))
six.assertCountEqual(
self,
self.assertCountEqual(
self.isos.linker.link.call_args_list,
[
self._linkCall(
@ -372,8 +365,7 @@ class TestCreaterepo(PungiTestCase):
cr.return_value.get_createrepo_cmd.side_effect = self.mock_cr
self.isos.createrepo()
six.assertCountEqual(
self,
self.assertCountEqual(
run.call_args_list,
[
mock.call(("src/Client", None), show_cmd=True),
@ -430,8 +422,7 @@ class TestCreaterepo(PungiTestCase):
cr.return_value.get_modifyrepo_cmd.side_effect = self.mock_mr
self.isos.createrepo()
six.assertCountEqual(
self,
self.assertCountEqual(
run.call_args_list,
[
mock.call(("src/Client", None), show_cmd=True),
@ -527,8 +518,7 @@ class TestDiscinfo(PungiTestCase):
@mock.patch("pungi_utils.unified_isos.create_discinfo")
def test_discinfo(self, create_discinfo):
self.isos.discinfo()
six.assertCountEqual(
self,
self.assertCountEqual(
create_discinfo.call_args_list,
[
mock.call(
@ -687,7 +677,7 @@ class TestCreateiso(PungiTestCase):
),
]
)
six.assertCountEqual(self, self.isos.linker.link.call_args_list, expected)
self.assertCountEqual(self.isos.linker.link.call_args_list, expected)
@mock.patch("pungi_utils.unified_isos.iso")
@mock.patch("pungi_utils.unified_isos.run")
@ -758,8 +748,7 @@ class TestUpdateChecksums(PungiTestCase):
@mock.patch("pungi_utils.unified_isos.make_checksums")
def test_update_checksums(self, mmc):
self.isos.update_checksums()
six.assertCountEqual(
self,
self.assertCountEqual(
mmc.call_args_list,
[
mock.call(
@ -776,8 +765,7 @@ class TestUpdateChecksums(PungiTestCase):
def test_update_checksums_one_file(self, mmc):
self.isos.conf["media_checksum_one_file"] = True
self.isos.update_checksums()
six.assertCountEqual(
self,
self.assertCountEqual(
mmc.call_args_list,
[
mock.call(

View File

@ -8,7 +8,6 @@ import unittest
import tempfile
import shutil
import subprocess
import six
from pungi import compose
from pungi import util
@ -251,7 +250,7 @@ class TestGetVariantData(unittest.TestCase):
def test_get_make_list(self):
conf = {"foo": {"^Client$": [1, 2], "^.*$": 3}}
result = util.get_variant_data(conf, "foo", mock.Mock(uid="Client"))
six.assertCountEqual(self, result, [1, 2, 3])
self.assertCountEqual(result, [1, 2, 3])
def test_not_matching_arch(self):
conf = {"foo": {"^Client$": [1, 2]}}
@ -1050,7 +1049,7 @@ class TestMoveAll(PungiTestCase):
self.assertFalse(os.path.isfile(os.path.join(self.src, "target")))
@mock.patch("six.moves.urllib.request.urlretrieve")
@mock.patch("urllib.request.urlretrieve")
class TestAsLocalFile(PungiTestCase):
def test_local_file(self, urlretrieve):
with util.as_local_file("/tmp/foo") as fn:

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import unittest
from six.moves import cStringIO
from io import StringIO
from pungi.wrappers.variants import VariantsXmlParser
@ -18,7 +18,7 @@ VARIANTS_WITH_WHITESPACE = """
class TestVariantsXmlParser(unittest.TestCase):
def test_whitespace_in_file(self):
input = cStringIO(VARIANTS_WITH_WHITESPACE)
input = StringIO(VARIANTS_WITH_WHITESPACE)
with self.assertRaises(ValueError) as ctx:
VariantsXmlParser(input)