diff --git a/backend/tests/daemons/test_log.py b/backend/tests/daemons/test_log.py index 73b1a777a..8b51c75ee 100644 --- a/backend/tests/daemons/test_log.py +++ b/backend/tests/daemons/test_log.py @@ -15,13 +15,13 @@ from copr_backend.daemons.log import RedisLogHandler -@pytest.yield_fixture +@pytest.fixture def mc_logging(): with mock.patch("copr_backend.daemons.log.logging") as mc_logging: yield mc_logging -@pytest.yield_fixture +@pytest.fixture def mc_setproctitle(): with mock.patch("copr_backend.daemons.log.setproctitle") as mc_spt: yield mc_spt diff --git a/backend/tests/daemons/unused_test_job_grab.py b/backend/tests/daemons/unused_test_job_grab.py index be3e64c56..455dc38b5 100644 --- a/backend/tests/daemons/unused_test_job_grab.py +++ b/backend/tests/daemons/unused_test_job_grab.py @@ -26,19 +26,19 @@ MODULE_REF = "copr_backend.daemons.job_grab" -@pytest.yield_fixture +@pytest.fixture def mc_logging(): with mock.patch("{}.logging".format(MODULE_REF)) as mc_logging: yield mc_logging -@pytest.yield_fixture +@pytest.fixture def mc_setproctitle(): with mock.patch("{}.setproctitle".format(MODULE_REF)) as mc_spt: yield mc_spt -@pytest.yield_fixture +@pytest.fixture def mc_retask_queue(): with mock.patch("{}.jobgrabcontrol.Channel".format(MODULE_REF)) as mc_queue: def make_queue(*args, **kwargs): @@ -51,7 +51,7 @@ def make_queue(*args, **kwargs): yield mc_queue -@pytest.yield_fixture +@pytest.fixture def mc_grc(): with mock.patch("{}.get_redis_connection".format(MODULE_REF)) as handle: yield handle @@ -119,7 +119,7 @@ def teardown_method(self, method): for handler in logging.root.handlers[:]: logging.root.removeHandler(handler) - @pytest.yield_fixture + @pytest.fixture def mc_time(self): with mock.patch("{}.time".format(MODULE_REF)) as mc_time: mc_time.time.return_value = self.test_time diff --git a/backend/tests/run/test_copr_prune_results.py b/backend/tests/run/test_copr_prune_results.py index 454087e23..570845337 100644 --- a/backend/tests/run/test_copr_prune_results.py +++ b/backend/tests/run/test_copr_prune_results.py @@ -18,22 +18,22 @@ MODULE_REF = 'run.copr_prune_results' -@pytest.yield_fixture +@pytest.fixture def mc_runcmd(): with mock.patch('{}.runcmd'.format(MODULE_REF)) as handle: yield handle -@pytest.yield_fixture +@pytest.fixture def mc_bcr(): with mock.patch('{}.BackendConfigReader'.format(MODULE_REF)) as handle: yield handle -@pytest.yield_fixture +@pytest.fixture def mc_build_devel(): with mock.patch('{}.uses_devel_repo'.format(MODULE_REF)) as handle: yield handle -@pytest.yield_fixture +@pytest.fixture def mc_pruner(): with mock.patch('{}.Pruner'.format(MODULE_REF)) as handle: yield handle diff --git a/backend/tests/test_frontend.py b/backend/tests/test_frontend.py index eeb8dc8f4..0adc98f39 100644 --- a/backend/tests/test_frontend.py +++ b/backend/tests/test_frontend.py @@ -11,7 +11,7 @@ from unittest.mock import MagicMock import pytest -@pytest.yield_fixture +@pytest.fixture def post_req(): with mock.patch("copr_common.request.post") as obj: yield obj @@ -26,7 +26,7 @@ def f_request_method(request): yield (request.param, ctx) -@pytest.yield_fixture +@pytest.fixture def mc_time(): with mock.patch("copr_common.request.time") as obj: yield obj diff --git a/cli/tests/cli_tests_lib.py b/cli/tests/cli_tests_lib.py index 3bbfc5a23..49144f375 100644 --- a/cli/tests/cli_tests_lib.py +++ b/cli/tests/cli_tests_lib.py @@ -16,7 +16,7 @@ "token": "abc", } -@pytest.yield_fixture +@pytest.fixture def f_test_config(): with mock.patch('copr_cli.main.config_from_file', return_value=config) as test_config: diff --git a/cli/tests/test_distgit.py b/cli/tests/test_distgit.py index 1223c7abd..90fc2ac1f 100644 --- a/cli/tests/test_distgit.py +++ b/cli/tests/test_distgit.py @@ -50,7 +50,7 @@ class TestDistGitMethodBuild(object): } @staticmethod - @pytest.yield_fixture + @pytest.fixture def f_patch_create_from_distgit(f_test_config, capsys): with mock.patch("copr.v3.proxies.build.BuildProxy.create_from_distgit") as patch: patch.return_value = [Munch({ @@ -102,7 +102,7 @@ class TestDistGitMethodPackage(object): success_stdout = "Create or edit operation was successful.\n" @staticmethod - @pytest.yield_fixture + @pytest.fixture def f_patch_package_distgit(f_test_config, capsys): with mock.patch("copr.v3.proxies.package.PackageProxy.add") as p1: with mock.patch("copr.v3.proxies.package.PackageProxy.edit") as p2: diff --git a/cli/tests/test_mock_config.py b/cli/tests/test_mock_config.py index 60d812924..a636a3ad5 100644 --- a/cli/tests/test_mock_config.py +++ b/cli/tests/test_mock_config.py @@ -77,7 +77,7 @@ def get_build_config_result(self): "isolation": "default" }) - @pytest.yield_fixture + @pytest.fixture def f_get_build_config(self): method = ( 'copr.v3.proxies.project_chroot.' diff --git a/dist-git/tests/test_crazy_merging.py b/dist-git/tests/test_crazy_merging.py index 77421d181..2bde1b6f0 100644 --- a/dist-git/tests/test_crazy_merging.py +++ b/dist-git/tests/test_crazy_merging.py @@ -15,25 +15,25 @@ def scriptdir(): return os.path.dirname(os.path.realpath(__file__)) -@pytest.yield_fixture +@pytest.fixture def mc_setup_git_repo(): with mock.patch("{}.setup_git_repo".format('copr_dist_git.package_import')) as handle: yield handle -@pytest.yield_fixture +@pytest.fixture def mc_group(): with mock.patch("os.setgid") as handle: yield handle -@pytest.yield_fixture +@pytest.fixture def mc_chroot(): with mock.patch("os.chroot") as handle: yield handle -@pytest.yield_fixture(scope='module') +@pytest.fixture(scope='module') def tmpdir(): origdir = os.getcwd() tdir = tempfile.mkdtemp() @@ -44,7 +44,7 @@ def tmpdir(): shutil.rmtree(tdir, ignore_errors=True) -@pytest.yield_fixture +@pytest.fixture def git_repos(tmpdir): dirname = 'git_repos' os.mkdir(dirname) @@ -52,7 +52,7 @@ def git_repos(tmpdir): shutil.rmtree('git_repos', ignore_errors=True) -@pytest.yield_fixture +@pytest.fixture def origin(git_repos): print("creating origin") modulename = 'bob/blah/quick-package' @@ -76,7 +76,7 @@ def origin(git_repos): shutil.rmtree('work', ignore_errors=True) -@pytest.yield_fixture +@pytest.fixture def branches(origin): branches = ['f20', 'epel7', 'el6', 'fedora/26', 'rhel-7'] middle_branches = ['el6', 'fedora/26'] @@ -97,7 +97,7 @@ def branches(origin): yield (origin, branches, middle_branches, border_branches) -@pytest.yield_fixture +@pytest.fixture def lookaside(tmpdir): assert 0 == os.system( """ set -e @@ -107,7 +107,7 @@ def lookaside(tmpdir): shutil.rmtree('lookaside', ignore_errors=True) -@pytest.yield_fixture +@pytest.fixture def opts_basic(tmpdir, lookaside): class _: pass diff --git a/dist-git/tests/test_importer.py b/dist-git/tests/test_importer.py index 3b712f691..0d9ec7a94 100644 --- a/dist-git/tests/test_importer.py +++ b/dist-git/tests/test_importer.py @@ -19,37 +19,37 @@ MODULE_REF = 'copr_dist_git.importer' -@pytest.yield_fixture +@pytest.fixture def mc_helpers(): with mock.patch("{}.helpers".format(MODULE_REF)) as handle: yield handle -@pytest.yield_fixture +@pytest.fixture def mc_worker(): with mock.patch("{}.Worker".format(MODULE_REF)) as handle: yield handle -@pytest.yield_fixture +@pytest.fixture def mc_import_package(): with mock.patch("{}.import_package".format(MODULE_REF)) as handle: yield handle -@pytest.yield_fixture +@pytest.fixture def mc_time(): with mock.patch("{}.time".format(MODULE_REF)) as handle: yield handle -@pytest.yield_fixture +@pytest.fixture def mc_get(): with mock.patch("{}.get".format(MODULE_REF)) as handle: yield handle -@pytest.yield_fixture +@pytest.fixture def mc_post(): with mock.patch("{}.post".format(MODULE_REF)) as handle: yield handle diff --git a/dist-git/tests/test_package_import.py b/dist-git/tests/test_package_import.py index eb54eba85..4347ce17a 100644 --- a/dist-git/tests/test_package_import.py +++ b/dist-git/tests/test_package_import.py @@ -23,49 +23,49 @@ MODULE_REF = 'copr_dist_git.package_import' -@pytest.yield_fixture +@pytest.fixture def mc_os_setgid(): with mock.patch("{}.os.setgid".format(MODULE_REF)) as handle: yield handle -@pytest.yield_fixture +@pytest.fixture def mc_subprocess_check_output(): with mock.patch("{}.subprocess.check_output".format(MODULE_REF)) as handle: yield handle -@pytest.yield_fixture +@pytest.fixture def mc_helpers(): with mock.patch("{}.helpers".format(MODULE_REF)) as handle: yield handle -@pytest.yield_fixture +@pytest.fixture def mc_shutil(): with mock.patch("{}.shutil".format(MODULE_REF)) as handle: yield handle -@pytest.yield_fixture +@pytest.fixture def mc_sync_branch(): with mock.patch("{}.sync_branch".format(MODULE_REF)) as handle: yield handle -@pytest.yield_fixture +@pytest.fixture def mc_refresh_cgit_listing(): with mock.patch("{}.refresh_cgit_listing".format(MODULE_REF)) as handle: yield handle -@pytest.yield_fixture +@pytest.fixture def mc_setup_git_repo(): with mock.patch("{}.setup_git_repo".format(MODULE_REF)) as handle: yield handle -@pytest.yield_fixture +@pytest.fixture def mc_pyrpkg_commands(): with mock.patch("{}.Commands".format(MODULE_REF)) as handle: yield handle diff --git a/rpmbuild/tests/test_mock.py b/rpmbuild/tests/test_mock.py index 9b6cc7a98..fe43e0bda 100644 --- a/rpmbuild/tests/test_mock.py +++ b/rpmbuild/tests/test_mock.py @@ -17,7 +17,7 @@ import mock builtins = '__builtin__' -@pytest.yield_fixture +@pytest.fixture def f_mock_calls(): p_popen = mock.patch('copr_rpmbuild.builders.mock.GentlyTimeoutedPopen')