From d8a553163fed0a72fcaac9f44e05a6ce5034f36a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Fri, 26 Jan 2024 09:38:32 +0200 Subject: [PATCH] Make python3-mock dependency optional MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://fedoraproject.org/wiki/Changes/RemovePythonMockUsage Prefer using unittest.mock to a standalone package. The separate packages should only really be needed on Python 2.7 these days. The test requirements file is updated to only require mock on old Python, and the dependency is removed from setup.py to avoid issues there. Relates: https://src.fedoraproject.org/rpms/pungi/pull-request/9 Signed-off-by: Lubomír Sedlář (cherry picked from commit ff5a7e637760f8ee230ca1f0d4855744f2c5af8c) --- setup.py | 2 +- test-requirements.txt | 2 +- tests/test_pkgset_pkgsets.py | 1 + tests/test_pkgset_source_koji.py | 10 ++-------- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index f2dae127..a28bc46c 100755 --- a/setup.py +++ b/setup.py @@ -66,5 +66,5 @@ setup( "dogpile.cache", ], extras_require={':python_version=="2.7"': ["enum34", "lockfile"]}, - tests_require=["mock", "pytest", "pytest-cov", "pyfakefs"], + tests_require=["pytest", "pytest-cov", "pyfakefs"], ) diff --git a/test-requirements.txt b/test-requirements.txt index 475f0328..2d921c76 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,4 +1,4 @@ -mock +mock; python_version < '3.3' parameterized pytest pytest-cov diff --git a/tests/test_pkgset_pkgsets.py b/tests/test_pkgset_pkgsets.py index 2fc81da6..aed56126 100644 --- a/tests/test_pkgset_pkgsets.py +++ b/tests/test_pkgset_pkgsets.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- + import ddt from unittest import mock import os diff --git a/tests/test_pkgset_source_koji.py b/tests/test_pkgset_source_koji.py index b270bd52..385db314 100644 --- a/tests/test_pkgset_source_koji.py +++ b/tests/test_pkgset_source_koji.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- import json - +import unittest +from unittest import mock import os import re import six @@ -10,13 +11,6 @@ from typing import AnyStr, List, Set, Dict, Tuple from tests.test_gather_method_hybrid import MockModule -try: - import unittest2 as unittest - from unittest2 import mock -except ImportError: - import unittest - from unittest import mock - from pungi.phases.pkgset.sources import source_koji, source_kojimock from tests import helpers from pungi.module_util import Modulemd