Make python3-mock dependency optional

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ář <lsedlar@redhat.com>

(cherry picked from commit ff5a7e6377)
This commit is contained in:
Lubomír Sedlář 2024-01-26 09:38:32 +02:00 committed by Stepan Oksanichenko
parent a9839d8078
commit d8a553163f
Signed by: soksanichenko
GPG Key ID: AB9983172AB1E45B
4 changed files with 5 additions and 10 deletions

View File

@ -66,5 +66,5 @@ setup(
"dogpile.cache", "dogpile.cache",
], ],
extras_require={':python_version=="2.7"': ["enum34", "lockfile"]}, extras_require={':python_version=="2.7"': ["enum34", "lockfile"]},
tests_require=["mock", "pytest", "pytest-cov", "pyfakefs"], tests_require=["pytest", "pytest-cov", "pyfakefs"],
) )

View File

@ -1,4 +1,4 @@
mock mock; python_version < '3.3'
parameterized parameterized
pytest pytest
pytest-cov pytest-cov

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import ddt import ddt
from unittest import mock from unittest import mock
import os import os

View File

@ -1,7 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import json import json
import unittest
from unittest import mock
import os import os
import re import re
import six import six
@ -10,13 +11,6 @@ from typing import AnyStr, List, Set, Dict, Tuple
from tests.test_gather_method_hybrid import MockModule 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 pungi.phases.pkgset.sources import source_koji, source_kojimock
from tests import helpers from tests import helpers
from pungi.module_util import Modulemd from pungi.module_util import Modulemd