From 228c2cce5132a801ccc926132a8271ee98621122 Mon Sep 17 00:00:00 2001 From: Evgenii Alekseev Date: Mon, 14 Jul 2025 20:33:54 +0300 Subject: [PATCH] style: use parebtgeses-less exceptions in side effects (tests only) --- .../application/test_application_packages.py | 2 +- .../test_application_repository.py | 4 +- .../application/handlers/test_handler.py | 4 +- tests/ahriman/application/test_lock.py | 2 +- tests/ahriman/core/alpm/remote/test_aur.py | 4 +- .../ahriman/core/alpm/remote/test_official.py | 4 +- tests/ahriman/core/alpm/test_pacman.py | 2 +- .../ahriman/core/alpm/test_pacman_database.py | 2 +- tests/ahriman/core/alpm/test_repo.py | 2 +- tests/ahriman/core/auth/test_oauth.py | 4 +- .../migrations/test_migrations_init.py | 4 +- .../distributed/test_distributed_system.py | 8 +- .../core/gitremote/test_remote_pull.py | 2 +- .../core/gitremote/test_remote_push.py | 2 +- .../core/http/test_sync_ahriman_client.py | 4 +- .../core/http/test_sync_http_client.py | 4 +- .../ahriman/core/log/test_http_log_handler.py | 4 +- tests/ahriman/core/log/test_log_loader.py | 2 +- tests/ahriman/core/report/test_report.py | 2 +- tests/ahriman/core/report/test_telegram.py | 4 +- .../ahriman/core/repository/test_executor.py | 8 +- .../core/repository/test_package_info.py | 2 +- .../core/repository/test_update_handler.py | 6 +- tests/ahriman/core/sign/test_gpg.py | 2 +- tests/ahriman/core/status/test_web_client.py | 136 +++++++++--------- .../core/triggers/test_trigger_loader.py | 6 +- tests/ahriman/core/upload/test_github.py | 2 +- tests/ahriman/core/upload/test_upload.py | 2 +- tests/ahriman/models/test_package.py | 2 +- tests/ahriman/models/test_package_source.py | 2 +- .../web/middlewares/test_exception_handler.py | 10 +- tests/ahriman/web/test_web.py | 2 +- .../v1/service/test_view_v1_service_pgp.py | 2 +- .../v1/status/test_view_v1_status_status.py | 2 +- .../views/v1/user/test_view_v1_user_logout.py | 2 +- 35 files changed, 126 insertions(+), 126 deletions(-) diff --git a/tests/ahriman/application/application/test_application_packages.py b/tests/ahriman/application/application/test_application_packages.py index 882ebd38..ec8e2553 100644 --- a/tests/ahriman/application/application/test_application_packages.py +++ b/tests/ahriman/application/application/test_application_packages.py @@ -141,7 +141,7 @@ def test_add_remote_missing(application_packages: ApplicationPackages, mocker: M """ must raise UnknownPackageError if remote package wasn't found """ - mocker.patch("requests.get", side_effect=Exception()) + mocker.patch("requests.get", side_effect=Exception) with pytest.raises(UnknownPackageError): application_packages._add_remote("url") diff --git a/tests/ahriman/application/application/test_application_repository.py b/tests/ahriman/application/application/test_application_repository.py index 531b4e5a..de1a545d 100644 --- a/tests/ahriman/application/application/test_application_repository.py +++ b/tests/ahriman/application/application/test_application_repository.py @@ -135,7 +135,7 @@ def test_unknown_no_aur(application_repository: ApplicationRepository, package_a must return empty list in case if there is locally stored PKGBUILD """ mocker.patch("ahriman.core.repository.repository.Repository.packages", return_value=[package_ahriman]) - mocker.patch("ahriman.models.package.Package.from_aur", side_effect=Exception()) + mocker.patch("ahriman.models.package.Package.from_aur", side_effect=Exception) mocker.patch("ahriman.models.package.Package.from_build", return_value=package_ahriman) mocker.patch("pathlib.Path.is_dir", return_value=True) mocker.patch("ahriman.core.build_tools.sources.Sources.has_remotes", return_value=False) @@ -149,7 +149,7 @@ def test_unknown_no_aur_no_local(application_repository: ApplicationRepository, must return list of packages missing in aur and in local storage """ mocker.patch("ahriman.core.repository.repository.Repository.packages", return_value=[package_ahriman]) - mocker.patch("ahriman.models.package.Package.from_aur", side_effect=Exception()) + mocker.patch("ahriman.models.package.Package.from_aur", side_effect=Exception) mocker.patch("pathlib.Path.is_dir", return_value=False) packages = application_repository.unknown() diff --git a/tests/ahriman/application/handlers/test_handler.py b/tests/ahriman/application/handlers/test_handler.py index 90258437..dc8001b2 100644 --- a/tests/ahriman/application/handlers/test_handler.py +++ b/tests/ahriman/application/handlers/test_handler.py @@ -46,7 +46,7 @@ def test_call_exception(args: argparse.Namespace, configuration: Configuration, """ args.configuration = Path("") args.quiet = False - mocker.patch("ahriman.core.configuration.Configuration.from_path", side_effect=Exception()) + mocker.patch("ahriman.core.configuration.Configuration.from_path", side_effect=Exception) logging_mock = mocker.patch("logging.Logger.exception") _, repository_id = configuration.check_loaded() @@ -60,7 +60,7 @@ def test_call_exit_code(args: argparse.Namespace, configuration: Configuration, """ args.configuration = Path("") args.quiet = False - mocker.patch("ahriman.core.configuration.Configuration.from_path", side_effect=ExitCode()) + mocker.patch("ahriman.core.configuration.Configuration.from_path", side_effect=ExitCode) logging_mock = mocker.patch("logging.Logger.exception") _, repository_id = configuration.check_loaded() diff --git a/tests/ahriman/application/test_lock.py b/tests/ahriman/application/test_lock.py index 910492e9..994b82ba 100644 --- a/tests/ahriman/application/test_lock.py +++ b/tests/ahriman/application/test_lock.py @@ -230,7 +230,7 @@ def test_clear_close_exception(lock: Lock) -> None: must suppress IO exception on file closure """ close_mock = lock._pid_file = MagicMock() - close_mock.close.side_effect = IOError() + close_mock.close.side_effect = IOError lock.clear() diff --git a/tests/ahriman/core/alpm/remote/test_aur.py b/tests/ahriman/core/alpm/remote/test_aur.py index 216f43b9..13e8096f 100644 --- a/tests/ahriman/core/alpm/remote/test_aur.py +++ b/tests/ahriman/core/alpm/remote/test_aur.py @@ -108,7 +108,7 @@ def test_aur_request_failed(aur: AUR, mocker: MockerFixture) -> None: """ must reraise generic exception """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) with pytest.raises(Exception): aur.aur_request("info", "ahriman") @@ -116,7 +116,7 @@ def test_aur_request_failed(aur: AUR, mocker: MockerFixture) -> None: def test_aur_request_failed_http_error(aur: AUR, mocker: MockerFixture) -> None: """ must reraise http exception """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) with pytest.raises(requests.HTTPError): aur.aur_request("info", "ahriman") diff --git a/tests/ahriman/core/alpm/remote/test_official.py b/tests/ahriman/core/alpm/remote/test_official.py index 5e1fa82a..348afe85 100644 --- a/tests/ahriman/core/alpm/remote/test_official.py +++ b/tests/ahriman/core/alpm/remote/test_official.py @@ -80,7 +80,7 @@ def test_arch_request_failed(official: Official, mocker: MockerFixture) -> None: """ must reraise generic exception """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) with pytest.raises(Exception): official.arch_request("akonadi", by="q") @@ -89,7 +89,7 @@ def test_arch_request_failed_http_error(official: Official, mocker: MockerFixtur """ must reraise http exception """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) with pytest.raises(requests.HTTPError): official.arch_request("akonadi", by="q") diff --git a/tests/ahriman/core/alpm/test_pacman.py b/tests/ahriman/core/alpm/test_pacman.py index b14c4881..a5655b14 100644 --- a/tests/ahriman/core/alpm/test_pacman.py +++ b/tests/ahriman/core/alpm/test_pacman.py @@ -242,7 +242,7 @@ def test_files_no_entry(pacman: Pacman, pyalpm_package_ahriman: pyalpm.Package, pacman.handle = handle_mock tar_mock = MagicMock() - tar_mock.extractfile.side_effect = KeyError() + tar_mock.extractfile.side_effect = KeyError open_mock = MagicMock() open_mock.__enter__.return_value = tar_mock diff --git a/tests/ahriman/core/alpm/test_pacman_database.py b/tests/ahriman/core/alpm/test_pacman_database.py index e8d83b36..4dcc0d53 100644 --- a/tests/ahriman/core/alpm/test_pacman_database.py +++ b/tests/ahriman/core/alpm/test_pacman_database.py @@ -131,7 +131,7 @@ def test_sync_exception(pacman_database: PacmanDatabase, mocker: MockerFixture) """ must suppress all exceptions on failure """ - mocker.patch("ahriman.core.alpm.pacman_database.PacmanDatabase.sync_packages", side_effect=Exception()) + mocker.patch("ahriman.core.alpm.pacman_database.PacmanDatabase.sync_packages", side_effect=Exception) pacman_database.sync(force=True) diff --git a/tests/ahriman/core/alpm/test_repo.py b/tests/ahriman/core/alpm/test_repo.py index db52b1e3..8cc87036 100644 --- a/tests/ahriman/core/alpm/test_repo.py +++ b/tests/ahriman/core/alpm/test_repo.py @@ -52,7 +52,7 @@ def test_repo_remove_fail_no_file(repo: Repo, mocker: MockerFixture) -> None: must fail on missing file """ mocker.patch("pathlib.Path.glob", return_value=[Path("package.pkg.tar.xz")]) - mocker.patch("pathlib.Path.unlink", side_effect=FileNotFoundError()) + mocker.patch("pathlib.Path.unlink", side_effect=FileNotFoundError) with pytest.raises(FileNotFoundError): repo.remove("package", Path("package.pkg.tar.xz")) diff --git a/tests/ahriman/core/auth/test_oauth.py b/tests/ahriman/core/auth/test_oauth.py index 5575cccd..2f6ceb99 100644 --- a/tests/ahriman/core/auth/test_oauth.py +++ b/tests/ahriman/core/auth/test_oauth.py @@ -90,7 +90,7 @@ async def test_get_oauth_username_exception_1(oauth: OAuth, mocker: MockerFixtur """ must return None in case of OAuth request error (get_access_token) """ - mocker.patch("aioauth_client.GoogleClient.get_access_token", side_effect=Exception()) + mocker.patch("aioauth_client.GoogleClient.get_access_token", side_effect=Exception) user_info_mock = mocker.patch("aioauth_client.GoogleClient.user_info") email = await oauth.get_oauth_username("code") @@ -103,7 +103,7 @@ async def test_get_oauth_username_exception_2(oauth: OAuth, mocker: MockerFixtur must return None in case of OAuth request error (user_info) """ mocker.patch("aioauth_client.GoogleClient.get_access_token", return_value=("token", "")) - mocker.patch("aioauth_client.GoogleClient.user_info", side_effect=Exception()) + mocker.patch("aioauth_client.GoogleClient.user_info", side_effect=Exception) email = await oauth.get_oauth_username("code") assert email is None diff --git a/tests/ahriman/core/database/migrations/test_migrations_init.py b/tests/ahriman/core/database/migrations/test_migrations_init.py index 8e1c19a5..e8a834bf 100644 --- a/tests/ahriman/core/database/migrations/test_migrations_init.py +++ b/tests/ahriman/core/database/migrations/test_migrations_init.py @@ -42,7 +42,7 @@ def test_apply_migration_exception(migrations: Migrations, mocker: MockerFixture must roll back and close cursor on exception during migration """ cursor = MagicMock() - mocker.patch("logging.Logger.info", side_effect=Exception()) + mocker.patch("logging.Logger.info", side_effect=Exception) migrations.connection.cursor.return_value = cursor with pytest.raises(Exception): @@ -59,7 +59,7 @@ def test_apply_migration_sql_exception(migrations: Migrations) -> None: must close cursor on general migration error """ cursor = MagicMock() - cursor.execute.side_effect = Exception() + cursor.execute.side_effect = Exception migrations.connection.cursor.return_value = cursor with pytest.raises(Exception): diff --git a/tests/ahriman/core/distributed/test_distributed_system.py b/tests/ahriman/core/distributed/test_distributed_system.py index 8965b0f5..9e736ae0 100644 --- a/tests/ahriman/core/distributed/test_distributed_system.py +++ b/tests/ahriman/core/distributed/test_distributed_system.py @@ -37,7 +37,7 @@ def test_register_failed(distributed_system: DistributedSystem, mocker: MockerFi """ must suppress any exception happened during worker registration """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) distributed_system.register() @@ -45,7 +45,7 @@ def test_register_failed_http_error(distributed_system: DistributedSystem, mocke """ must suppress HTTP exception happened during worker registration """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) distributed_system.register() @@ -70,7 +70,7 @@ def test_workers_failed(distributed_system: DistributedSystem, mocker: MockerFix """ must suppress any exception happened during worker extraction """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) distributed_system.workers() @@ -78,5 +78,5 @@ def test_workers_failed_http_error(distributed_system: DistributedSystem, mocker """ must suppress HTTP exception happened during worker extraction """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) distributed_system.workers() diff --git a/tests/ahriman/core/gitremote/test_remote_pull.py b/tests/ahriman/core/gitremote/test_remote_pull.py index 219336ab..384e9d57 100644 --- a/tests/ahriman/core/gitremote/test_remote_pull.py +++ b/tests/ahriman/core/gitremote/test_remote_pull.py @@ -85,7 +85,7 @@ def test_run_failed(configuration: Configuration, mocker: MockerFixture) -> None """ must reraise exception on error occurred """ - mocker.patch("ahriman.core.gitremote.remote_pull.RemotePull.repo_clone", side_effect=Exception()) + mocker.patch("ahriman.core.gitremote.remote_pull.RemotePull.repo_clone", side_effect=Exception) _, repository_id = configuration.check_loaded() runner = RemotePull(repository_id, configuration, "gitremote") diff --git a/tests/ahriman/core/gitremote/test_remote_push.py b/tests/ahriman/core/gitremote/test_remote_push.py index 3d8a4007..c12a44f8 100644 --- a/tests/ahriman/core/gitremote/test_remote_push.py +++ b/tests/ahriman/core/gitremote/test_remote_push.py @@ -82,7 +82,7 @@ def test_run_failed(local_client: Client, configuration: Configuration, result: """ must reraise exception on error occurred """ - mocker.patch("ahriman.core.build_tools.sources.Sources.fetch", side_effect=Exception()) + mocker.patch("ahriman.core.build_tools.sources.Sources.fetch", side_effect=Exception) runner = RemotePush(local_client, configuration, "gitremote") with pytest.raises(GitRemoteError): diff --git a/tests/ahriman/core/http/test_sync_ahriman_client.py b/tests/ahriman/core/http/test_sync_ahriman_client.py index 2a83bcac..4d7e42ea 100644 --- a/tests/ahriman/core/http/test_sync_ahriman_client.py +++ b/tests/ahriman/core/http/test_sync_ahriman_client.py @@ -51,7 +51,7 @@ def test_login_failed(ahriman_client: SyncAhrimanClient, user: User, mocker: Moc must suppress any exception happened during login """ ahriman_client.user = user - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) ahriman_client._login(requests.Session()) @@ -60,7 +60,7 @@ def test_login_failed_http_error(ahriman_client: SyncAhrimanClient, user: User, must suppress HTTP exception happened during login """ ahriman_client.user = user - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) ahriman_client._login(requests.Session()) diff --git a/tests/ahriman/core/http/test_sync_http_client.py b/tests/ahriman/core/http/test_sync_http_client.py index 74648fb6..c7a194fd 100644 --- a/tests/ahriman/core/http/test_sync_http_client.py +++ b/tests/ahriman/core/http/test_sync_http_client.py @@ -124,7 +124,7 @@ def test_make_request_failed(mocker: MockerFixture) -> None: """ must process request errors """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) logging_mock = mocker.patch("logging.Logger.exception") with pytest.raises(Exception): @@ -136,7 +136,7 @@ def test_make_request_suppress_errors(mocker: MockerFixture) -> None: """ must suppress request errors correctly """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) logging_mock = mocker.patch("logging.Logger.exception") with pytest.raises(Exception): diff --git a/tests/ahriman/core/log/test_http_log_handler.py b/tests/ahriman/core/log/test_http_log_handler.py index d8ba6d3e..56a9ca46 100644 --- a/tests/ahriman/core/log/test_http_log_handler.py +++ b/tests/ahriman/core/log/test_http_log_handler.py @@ -61,7 +61,7 @@ def test_emit_failed(configuration: Configuration, log_record: logging.LogRecord must call handle error on exception """ log_record.package_id = LogRecordId(package_ahriman.base, package_ahriman.version) - mocker.patch("ahriman.core.status.Client.package_logs_add", side_effect=Exception()) + mocker.patch("ahriman.core.status.Client.package_logs_add", side_effect=Exception) handle_error_mock = mocker.patch("logging.Handler.handleError") _, repository_id = configuration.check_loaded() handler = HttpLogHandler(repository_id, configuration, report=False, suppress_errors=False) @@ -76,7 +76,7 @@ def test_emit_suppress_failed(configuration: Configuration, log_record: logging. must not call handle error on exception if suppress flag is set """ log_record.package_id = LogRecordId(package_ahriman.base, package_ahriman.version) - mocker.patch("ahriman.core.status.Client.package_logs_add", side_effect=Exception()) + mocker.patch("ahriman.core.status.Client.package_logs_add", side_effect=Exception) handle_error_mock = mocker.patch("logging.Handler.handleError") _, repository_id = configuration.check_loaded() handler = HttpLogHandler(repository_id, configuration, report=False, suppress_errors=True) diff --git a/tests/ahriman/core/log/test_log_loader.py b/tests/ahriman/core/log/test_log_loader.py index c653da57..b7dd0c3d 100644 --- a/tests/ahriman/core/log/test_log_loader.py +++ b/tests/ahriman/core/log/test_log_loader.py @@ -61,7 +61,7 @@ def test_load_fallback(configuration: Configuration, mocker: MockerFixture) -> N """ must fall back to stderr without errors """ - mocker.patch("ahriman.core.log.log_loader.fileConfig", side_effect=PermissionError()) + mocker.patch("ahriman.core.log.log_loader.fileConfig", side_effect=PermissionError) _, repository_id = configuration.check_loaded() LogLoader.load(repository_id, configuration, LogHandler.Journald, quiet=False, report=False) diff --git a/tests/ahriman/core/report/test_report.py b/tests/ahriman/core/report/test_report.py index cc1e649c..06c737e8 100644 --- a/tests/ahriman/core/report/test_report.py +++ b/tests/ahriman/core/report/test_report.py @@ -13,7 +13,7 @@ def test_report_failure(configuration: Configuration, mocker: MockerFixture) -> """ must raise ReportFailed on errors """ - mocker.patch("ahriman.core.report.html.HTML.generate", side_effect=Exception()) + mocker.patch("ahriman.core.report.html.HTML.generate", side_effect=Exception) _, repository_id = configuration.check_loaded() with pytest.raises(ReportError): diff --git a/tests/ahriman/core/report/test_telegram.py b/tests/ahriman/core/report/test_telegram.py index ebe889aa..566d9270 100644 --- a/tests/ahriman/core/report/test_telegram.py +++ b/tests/ahriman/core/report/test_telegram.py @@ -41,7 +41,7 @@ def test_send_failed(telegram: Telegram, mocker: MockerFixture) -> None: """ must reraise generic exception """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) with pytest.raises(Exception): telegram._send("a text") @@ -50,7 +50,7 @@ def test_send_failed_http_error(telegram: Telegram, mocker: MockerFixture) -> No """ must reraise http exception """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) with pytest.raises(requests.HTTPError): telegram._send("a text") diff --git a/tests/ahriman/core/repository/test_executor.py b/tests/ahriman/core/repository/test_executor.py index 6431fd93..45e12d07 100644 --- a/tests/ahriman/core/repository/test_executor.py +++ b/tests/ahriman/core/repository/test_executor.py @@ -67,7 +67,7 @@ def test_process_build_failure(executor: Executor, package_ahriman: Package, moc mocker.patch("ahriman.core.repository.executor.Executor.packages_built") mocker.patch("ahriman.core.build_tools.task.Task.build", return_value=[Path(package_ahriman.base)]) mocker.patch("ahriman.core.build_tools.task.Task.init") - mocker.patch("shutil.move", side_effect=Exception()) + mocker.patch("shutil.move", side_effect=Exception) status_client_mock = mocker.patch("ahriman.core.status.Client.set_failed") executor.process_build([package_ahriman]) @@ -151,7 +151,7 @@ def test_process_remove_failed(executor: Executor, package_ahriman: Package, moc must suppress tree clear errors during package base removal """ mocker.patch("ahriman.core.repository.executor.Executor.packages", return_value=[package_ahriman]) - mocker.patch("ahriman.core.status.local_client.LocalClient.package_remove", side_effect=Exception()) + mocker.patch("ahriman.core.status.local_client.LocalClient.package_remove", side_effect=Exception) executor.process_remove([package_ahriman.base]) @@ -160,7 +160,7 @@ def test_process_remove_tree_clear_failed(executor: Executor, package_ahriman: P must suppress remove errors """ mocker.patch("ahriman.core.repository.executor.Executor.packages", return_value=[package_ahriman]) - mocker.patch("ahriman.core.alpm.repo.Repo.remove", side_effect=Exception()) + mocker.patch("ahriman.core.alpm.repo.Repo.remove", side_effect=Exception) executor.process_remove([package_ahriman.base]) @@ -277,7 +277,7 @@ def test_process_update_failed(executor: Executor, package_ahriman: Package, moc """ must process update for failed package """ - mocker.patch("shutil.move", side_effect=Exception()) + mocker.patch("shutil.move", side_effect=Exception) mocker.patch("ahriman.core.repository.executor.Executor.load_archives", return_value=[package_ahriman]) mocker.patch("ahriman.core.repository.executor.Executor.packages", return_value=[package_ahriman]) status_client_mock = mocker.patch("ahriman.core.status.Client.set_failed") diff --git a/tests/ahriman/core/repository/test_package_info.py b/tests/ahriman/core/repository/test_package_info.py index e228919e..e96818c0 100644 --- a/tests/ahriman/core/repository/test_package_info.py +++ b/tests/ahriman/core/repository/test_package_info.py @@ -40,7 +40,7 @@ def test_load_archives_failed(package_info: PackageInfo, mocker: MockerFixture) """ must skip packages which cannot be loaded """ - mocker.patch("ahriman.models.package.Package.from_archive", side_effect=Exception()) + mocker.patch("ahriman.models.package.Package.from_archive", side_effect=Exception) assert not package_info.load_archives([Path("a.pkg.tar.xz")]) diff --git a/tests/ahriman/core/repository/test_update_handler.py b/tests/ahriman/core/repository/test_update_handler.py index b4c4c0f6..8b6e4bcb 100644 --- a/tests/ahriman/core/repository/test_update_handler.py +++ b/tests/ahriman/core/repository/test_update_handler.py @@ -59,7 +59,7 @@ def test_updates_aur_failed(update_handler: UpdateHandler, package_ahriman: Pack must update status via client for failed load """ mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[package_ahriman]) - mocker.patch("ahriman.models.package.Package.from_aur", side_effect=Exception()) + mocker.patch("ahriman.models.package.Package.from_aur", side_effect=Exception) status_client_mock = mocker.patch("ahriman.core.status.Client.set_failed") update_handler.updates_aur([], vcs=True) @@ -281,7 +281,7 @@ def test_updates_local_with_failures(update_handler: UpdateHandler, package_ahri """ mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages") mocker.patch("pathlib.Path.iterdir", return_value=[Path(package_ahriman.base)]) - mocker.patch("ahriman.core.build_tools.sources.Sources.fetch", side_effect=Exception()) + mocker.patch("ahriman.core.build_tools.sources.Sources.fetch", side_effect=Exception) assert not update_handler.updates_local(vcs=True) @@ -336,6 +336,6 @@ def test_updates_manual_with_failures(update_handler: UpdateHandler, package_ahr """ must process manual through the packages with failure """ - mocker.patch("ahriman.core.database.SQLite.build_queue_get", side_effect=Exception()) + mocker.patch("ahriman.core.database.SQLite.build_queue_get", side_effect=Exception) mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[package_ahriman]) assert update_handler.updates_manual() == [] diff --git a/tests/ahriman/core/sign/test_gpg.py b/tests/ahriman/core/sign/test_gpg.py index ae5eda10..5df4e8a0 100644 --- a/tests/ahriman/core/sign/test_gpg.py +++ b/tests/ahriman/core/sign/test_gpg.py @@ -83,7 +83,7 @@ def test_key_download_failure(gpg: GPG, mocker: MockerFixture) -> None: """ must download the key from public server and log error if any (and raise it again) """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) with pytest.raises(requests.HTTPError): gpg.key_download("keyserver.ubuntu.com", "0xE989490C") diff --git a/tests/ahriman/core/status/test_web_client.py b/tests/ahriman/core/status/test_web_client.py index b6165d80..a9f22256 100644 --- a/tests/ahriman/core/status/test_web_client.py +++ b/tests/ahriman/core/status/test_web_client.py @@ -120,7 +120,7 @@ def test_configuration_reload_failed(web_client: WebClient, mocker: MockerFixtur """ must suppress any exception happened during configuration reload """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) web_client.configuration_reload() @@ -128,7 +128,7 @@ def test_configuration_reload_failed_http_error(web_client: WebClient, mocker: M """ must suppress HTTP exception happened during configuration reload """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) web_client.configuration_reload() @@ -137,7 +137,7 @@ def test_configuration_reload_failed_suppress(web_client: WebClient, mocker: Moc must suppress any exception happened during configuration reload and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) logging_mock = mocker.patch("logging.exception") web_client.configuration_reload() @@ -149,7 +149,7 @@ def test_configuration_reload_failed_http_error_suppress(web_client: WebClient, must suppress HTTP exception happened during configuration reload and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) logging_mock = mocker.patch("logging.exception") web_client.configuration_reload() @@ -172,7 +172,7 @@ def test_event_add_failed(web_client: WebClient, mocker: MockerFixture) -> None: """ must suppress any exception happened during events creation """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) web_client.event_add(Event("", "")) @@ -180,7 +180,7 @@ def test_event_add_failed_http_error(web_client: WebClient, mocker: MockerFixtur """ must suppress HTTP exception happened during events creation """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) web_client.event_add(Event("", "")) @@ -189,7 +189,7 @@ def test_event_add_failed_suppress(web_client: WebClient, mocker: MockerFixture) must suppress any exception happened during events creation and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) logging_mock = mocker.patch("logging.exception") web_client.event_add(Event("", "")) @@ -201,7 +201,7 @@ def test_event_add_failed_http_error_suppress(web_client: WebClient, mocker: Moc must suppress HTTP exception happened during events creation and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) logging_mock = mocker.patch("logging.exception") web_client.event_add(Event("", "")) @@ -271,7 +271,7 @@ def test_event_get_failed(web_client: WebClient, mocker: MockerFixture) -> None: """ must suppress any exception happened during events fetch """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) web_client.event_get(None, None) @@ -279,7 +279,7 @@ def test_event_get_failed_http_error(web_client: WebClient, mocker: MockerFixtur """ must suppress HTTP exception happened during events fetch """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) web_client.event_get(None, None) @@ -288,7 +288,7 @@ def test_event_get_failed_suppress(web_client: WebClient, mocker: MockerFixture) must suppress any exception happened during events fetch and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) logging_mock = mocker.patch("logging.exception") web_client.event_get(None, None) @@ -300,7 +300,7 @@ def test_event_get_failed_http_error_suppress(web_client: WebClient, mocker: Moc must suppress HTTP exception happened during events fetch and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) logging_mock = mocker.patch("logging.exception") web_client.event_get(None, None) @@ -322,7 +322,7 @@ def test_logs_rotate_failed(web_client: WebClient, mocker: MockerFixture) -> Non """ must suppress any exception happened during logs rotation """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) web_client.logs_rotate(42) @@ -330,7 +330,7 @@ def test_logs_rotate_failed_http_error(web_client: WebClient, mocker: MockerFixt """ must suppress HTTP exception happened during logs rotation """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) web_client.logs_rotate(42) @@ -339,7 +339,7 @@ def test_logs_rotate_failed_suppress(web_client: WebClient, mocker: MockerFixtur must suppress any exception happened during logs rotation and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) logging_mock = mocker.patch("logging.exception") web_client.logs_rotate(42) @@ -351,7 +351,7 @@ def test_logs_rotate_failed_http_error_suppress(web_client: WebClient, mocker: M must suppress HTTP exception happened during logs rotation and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) logging_mock = mocker.patch("logging.exception") web_client.logs_rotate(42) @@ -379,7 +379,7 @@ def test_package_changes_get_failed(web_client: WebClient, package_ahriman: Pack """ must suppress any exception happened during changes fetch """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) web_client.package_changes_get(package_ahriman.base) @@ -388,7 +388,7 @@ def test_package_changes_get_failed_http_error(web_client: WebClient, package_ah """ must suppress HTTP exception happened during changes fetch """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) web_client.package_changes_get(package_ahriman.base) @@ -398,7 +398,7 @@ def test_package_changes_get_failed_suppress(web_client: WebClient, package_ahri must suppress any exception happened during changes fetch and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) logging_mock = mocker.patch("logging.exception") web_client.package_changes_get(package_ahriman.base) @@ -411,7 +411,7 @@ def test_package_changes_get_failed_http_error_suppress(web_client: WebClient, p must suppress HTTP exception happened during changes fetch and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) logging_mock = mocker.patch("logging.exception") web_client.package_changes_get(package_ahriman.base) @@ -434,7 +434,7 @@ def test_package_changes_update_failed(web_client: WebClient, package_ahriman: P """ must suppress any exception happened during changes update """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) web_client.package_changes_update(package_ahriman.base, Changes()) @@ -443,7 +443,7 @@ def test_package_changes_update_failed_http_error(web_client: WebClient, package """ must suppress HTTP exception happened during changes update """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) web_client.package_changes_update(package_ahriman.base, Changes()) @@ -453,7 +453,7 @@ def test_package_changes_update_failed_suppress(web_client: WebClient, package_a must suppress any exception happened during changes update and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) logging_mock = mocker.patch("logging.exception") web_client.package_changes_update(package_ahriman.base, Changes()) @@ -466,7 +466,7 @@ def test_package_changes_update_failed_http_error_suppress(web_client: WebClient must suppress HTTP exception happened during changes update and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) logging_mock = mocker.patch("logging.exception") web_client.package_changes_update(package_ahriman.base, Changes()) @@ -495,7 +495,7 @@ def test_package_dependencies_get_failed(web_client: WebClient, package_ahriman: """ must suppress any exception happened during dependencies fetch """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) web_client.package_dependencies_get(package_ahriman.base) @@ -504,7 +504,7 @@ def test_package_dependencies_get_failed_http_error(web_client: WebClient, packa """ must suppress HTTP exception happened during dependencies fetch """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) web_client.package_dependencies_get(package_ahriman.base) @@ -514,7 +514,7 @@ def test_package_dependencies_get_failed_suppress(web_client: WebClient, package must suppress any exception happened during dependencies fetch and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) logging_mock = mocker.patch("logging.exception") web_client.package_dependencies_get(package_ahriman.base) @@ -527,7 +527,7 @@ def test_package_dependencies_get_failed_http_error_suppress(web_client: WebClie must suppress HTTP exception happened during dependencies fetch and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) logging_mock = mocker.patch("logging.exception") web_client.package_dependencies_get(package_ahriman.base) @@ -551,7 +551,7 @@ def test_package_dependencies_update_failed(web_client: WebClient, package_ahrim """ must suppress any exception happened during dependencies update """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) web_client.package_dependencies_update(package_ahriman.base, Dependencies()) @@ -560,7 +560,7 @@ def test_package_dependencies_update_failed_http_error(web_client: WebClient, pa """ must suppress HTTP exception happened during dependencies update """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) web_client.package_dependencies_update(package_ahriman.base, Dependencies()) @@ -570,7 +570,7 @@ def test_package_dependencies_update_failed_suppress(web_client: WebClient, pack must suppress any exception happened during dependencies update and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) logging_mock = mocker.patch("logging.exception") web_client.package_dependencies_update(package_ahriman.base, Dependencies()) @@ -583,7 +583,7 @@ def test_package_dependencies_update_failed_http_error_suppress(web_client: WebC must suppress HTTP exception happened during dependencies update and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) logging_mock = mocker.patch("logging.exception") web_client.package_dependencies_update(package_ahriman.base, Dependencies()) @@ -612,7 +612,7 @@ def test_package_get_failed(web_client: WebClient, mocker: MockerFixture) -> Non """ must suppress any exception happened during status getting """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) assert web_client.package_get(None) == [] @@ -620,7 +620,7 @@ def test_package_get_failed_http_error(web_client: WebClient, mocker: MockerFixt """ must suppress HTTP exception happened during status getting """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) assert web_client.package_get(None) == [] @@ -668,7 +668,7 @@ def test_package_logs_add_failed(web_client: WebClient, log_record: logging.LogR """ must pass exception during log post """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) log_record.package_base = package_ahriman.base record = LogRecord(LogRecordId(package_ahriman.base, package_ahriman.version), log_record.created, log_record.getMessage()) @@ -682,7 +682,7 @@ def test_package_logs_add_failed_http_error(web_client: WebClient, log_record: l """ must pass HTTP exception during log post """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) log_record.package_base = package_ahriman.base record = LogRecord(LogRecordId(package_ahriman.base, package_ahriman.version), log_record.created, log_record.getMessage()) @@ -734,7 +734,7 @@ def test_package_logs_get_failed(web_client: WebClient, package_ahriman: Package """ must suppress any exception happened during logs fetch """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) web_client.package_logs_get(package_ahriman.base) @@ -743,7 +743,7 @@ def test_package_logs_get_failed_http_error(web_client: WebClient, package_ahrim """ must suppress HTTP exception happened during logs fetch """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) web_client.package_logs_get(package_ahriman.base) @@ -753,7 +753,7 @@ def test_package_logs_get_failed_suppress(web_client: WebClient, package_ahriman must suppress any exception happened during logs fetch and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) logging_mock = mocker.patch("logging.exception") web_client.package_logs_get(package_ahriman.base) @@ -766,7 +766,7 @@ def test_package_logs_get_failed_http_error_suppress(web_client: WebClient, pack must suppress HTTP exception happened during logs fetch and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) logging_mock = mocker.patch("logging.exception") web_client.package_logs_get(package_ahriman.base) @@ -788,7 +788,7 @@ def test_package_logs_remove_failed(web_client: WebClient, package_ahriman: Pack """ must suppress any exception happened during logs removal """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) web_client.package_logs_remove(package_ahriman.base, "42") @@ -797,7 +797,7 @@ def test_package_logs_remove_failed_http_error(web_client: WebClient, package_ah """ must suppress HTTP exception happened during logs removal """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) web_client.package_logs_remove(package_ahriman.base, "42") @@ -807,7 +807,7 @@ def test_package_logs_remove_failed_suppress(web_client: WebClient, package_ahri must suppress any exception happened during logs removal and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) logging_mock = mocker.patch("logging.exception") web_client.package_logs_remove(package_ahriman.base, "42") @@ -820,7 +820,7 @@ def test_package_logs_remove_failed_http_error_suppress(web_client: WebClient, p must suppress HTTP exception happened during logs removal and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) logging_mock = mocker.patch("logging.exception") web_client.package_logs_remove(package_ahriman.base, "42") @@ -847,7 +847,7 @@ def test_package_patches_get_failed(web_client: WebClient, package_ahriman: Pack """ must suppress any exception happened during patches fetch """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) web_client.package_patches_get(package_ahriman.base, None) @@ -856,7 +856,7 @@ def test_package_patches_get_failed_http_error(web_client: WebClient, package_ah """ must suppress HTTP exception happened during patches fetch """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) web_client.package_patches_get(package_ahriman.base, None) @@ -866,7 +866,7 @@ def test_package_patches_get_failed_suppress(web_client: WebClient, package_ahri must suppress any exception happened during patches fetch and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) logging_mock = mocker.patch("logging.exception") web_client.package_patches_get(package_ahriman.base, None) @@ -879,7 +879,7 @@ def test_package_patches_get_failed_http_error_suppress(web_client: WebClient, p must suppress HTTP exception happened during patches fetch and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) logging_mock = mocker.patch("logging.exception") web_client.package_patches_get(package_ahriman.base, None) @@ -901,7 +901,7 @@ def test_package_patches_update_failed(web_client: WebClient, package_ahriman: P """ must suppress any exception happened during patches update """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) web_client.package_patches_update(package_ahriman.base, PkgbuildPatch("key", "value")) @@ -910,7 +910,7 @@ def test_package_patches_update_failed_http_error(web_client: WebClient, package """ must suppress HTTP exception happened during patches update """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) web_client.package_patches_update(package_ahriman.base, PkgbuildPatch("key", "value")) @@ -920,7 +920,7 @@ def test_package_patches_update_failed_suppress(web_client: WebClient, package_a must suppress any exception happened during patches update and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) logging_mock = mocker.patch("logging.exception") web_client.package_patches_update(package_ahriman.base, PkgbuildPatch("key", "value")) @@ -933,7 +933,7 @@ def test_package_patches_update_failed_http_error_suppress(web_client: WebClient must suppress HTTP exception happened during patches update and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) logging_mock = mocker.patch("logging.exception") web_client.package_patches_update(package_ahriman.base, PkgbuildPatch("key", "value")) @@ -954,7 +954,7 @@ def test_package_patches_remove_failed(web_client: WebClient, package_ahriman: P """ must suppress any exception happened during patches removal """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) web_client.package_patches_remove(package_ahriman.base, None) @@ -963,7 +963,7 @@ def test_package_patches_remove_failed_http_error(web_client: WebClient, package """ must suppress HTTP exception happened during patches removal """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) web_client.package_patches_remove(package_ahriman.base, None) @@ -973,7 +973,7 @@ def test_package_patches_remove_failed_suppress(web_client: WebClient, package_a must suppress any exception happened during patches removal and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) logging_mock = mocker.patch("logging.exception") web_client.package_patches_remove(package_ahriman.base, None) @@ -986,7 +986,7 @@ def test_package_patches_remove_failed_http_error_suppress(web_client: WebClient must suppress HTTP exception happened during patches removal and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) logging_mock = mocker.patch("logging.exception") web_client.package_patches_remove(package_ahriman.base, None) @@ -1008,7 +1008,7 @@ def test_package_remove_failed(web_client: WebClient, package_ahriman: Package, """ must suppress any exception happened during removal """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) web_client.package_remove(package_ahriman.base) @@ -1017,7 +1017,7 @@ def test_package_remove_failed_http_error(web_client: WebClient, package_ahriman """ must suppress HTTP exception happened during removal """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) web_client.package_remove(package_ahriman.base) @@ -1039,7 +1039,7 @@ def test_package_status_update_failed(web_client: WebClient, package_ahriman: Pa """ must suppress any exception happened during update """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) web_client.package_status_update(package_ahriman.base, BuildStatusEnum.Unknown) @@ -1048,7 +1048,7 @@ def test_package_status_update_failed_http_error(web_client: WebClient, package_ """ must suppress HTTP exception happened during update """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) web_client.package_status_update(package_ahriman.base, BuildStatusEnum.Unknown) @@ -1068,7 +1068,7 @@ def test_package_update_failed(web_client: WebClient, package_ahriman: Package, """ must suppress any exception happened during addition """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) web_client.package_update(package_ahriman, BuildStatusEnum.Unknown) @@ -1077,7 +1077,7 @@ def test_package_update_failed_http_error(web_client: WebClient, package_ahriman """ must suppress HTTP exception happened during addition """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) web_client.package_update(package_ahriman, BuildStatusEnum.Unknown) @@ -1086,7 +1086,7 @@ def test_package_update_failed_suppress(web_client: WebClient, package_ahriman: must suppress any exception happened during addition and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) logging_mock = mocker.patch("logging.exception") web_client.package_update(package_ahriman, BuildStatusEnum.Unknown) @@ -1099,7 +1099,7 @@ def test_package_update_failed_http_error_suppress(web_client: WebClient, packag must suppress HTTP exception happened during addition and don't log """ web_client.suppress_errors = True - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) logging_mock = mocker.patch("logging.exception") web_client.package_update(package_ahriman, BuildStatusEnum.Unknown) @@ -1127,7 +1127,7 @@ def test_status_get_failed(web_client: WebClient, mocker: MockerFixture) -> None """ must suppress any exception happened during web service status getting """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) assert web_client.status_get().architecture is None @@ -1135,7 +1135,7 @@ def test_status_get_failed_http_error(web_client: WebClient, mocker: MockerFixtu """ must suppress HTTP exception happened during web service status getting """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) assert web_client.status_get().architecture is None @@ -1159,7 +1159,7 @@ def test_status_update_self_failed(web_client: WebClient, mocker: MockerFixture) """ must suppress any exception happened during service update """ - mocker.patch("requests.Session.request", side_effect=Exception()) + mocker.patch("requests.Session.request", side_effect=Exception) web_client.status_update(BuildStatusEnum.Unknown) @@ -1167,5 +1167,5 @@ def test_status_update_failed_http_error(web_client: WebClient, mocker: MockerFi """ must suppress HTTP exception happened during service update """ - mocker.patch("requests.Session.request", side_effect=requests.HTTPError()) + mocker.patch("requests.Session.request", side_effect=requests.HTTPError) web_client.status_update(BuildStatusEnum.Unknown) diff --git a/tests/ahriman/core/triggers/test_trigger_loader.py b/tests/ahriman/core/triggers/test_trigger_loader.py index a4e99faa..f17b17a5 100644 --- a/tests/ahriman/core/triggers/test_trigger_loader.py +++ b/tests/ahriman/core/triggers/test_trigger_loader.py @@ -49,7 +49,7 @@ def test_load_trigger_package_error_on_creation(trigger_loader: TriggerLoader, c """ must raise InvalidException on trigger initialization if any exception is thrown """ - mocker.patch("ahriman.core.triggers.trigger.Trigger.__init__", side_effect=Exception()) + mocker.patch("ahriman.core.triggers.trigger.Trigger.__init__", side_effect=Exception) _, repository_id = configuration.check_loaded() with pytest.raises(ExtensionError): @@ -67,7 +67,7 @@ def test_load_trigger_class_package_invalid_import(trigger_loader: TriggerLoader """ must raise InvalidExtension on invalid import """ - mocker.patch("importlib.import_module", side_effect=ModuleNotFoundError()) + mocker.patch("importlib.import_module", side_effect=ModuleNotFoundError) with pytest.raises(ExtensionError): trigger_loader.load_trigger_class("random.module") @@ -137,7 +137,7 @@ def test_on_result_exception(trigger_loader: TriggerLoader, package_ahriman: Pac """ must suppress exception during trigger run """ - upload_mock = mocker.patch("ahriman.core.upload.UploadTrigger.on_result", side_effect=Exception()) + upload_mock = mocker.patch("ahriman.core.upload.UploadTrigger.on_result", side_effect=Exception) report_mock = mocker.patch("ahriman.core.report.ReportTrigger.on_result") log_mock = mocker.patch("logging.Logger.exception") diff --git a/tests/ahriman/core/upload/test_github.py b/tests/ahriman/core/upload/test_github.py index 045ad7a4..1a511b77 100644 --- a/tests/ahriman/core/upload/test_github.py +++ b/tests/ahriman/core/upload/test_github.py @@ -172,7 +172,7 @@ def test_release_get_exception(github: GitHub, mocker: MockerFixture) -> None: """ must re-raise non HTTPError exception """ - mocker.patch("ahriman.core.upload.github.GitHub.make_request", side_effect=Exception()) + mocker.patch("ahriman.core.upload.github.GitHub.make_request", side_effect=Exception) with pytest.raises(Exception): github.release_get() diff --git a/tests/ahriman/core/upload/test_upload.py b/tests/ahriman/core/upload/test_upload.py index b01666c8..a3fbe766 100644 --- a/tests/ahriman/core/upload/test_upload.py +++ b/tests/ahriman/core/upload/test_upload.py @@ -13,7 +13,7 @@ def test_upload_failure(configuration: Configuration, mocker: MockerFixture) -> """ must raise SyncFailed on errors """ - mocker.patch("ahriman.core.upload.rsync.Rsync.sync", side_effect=Exception()) + mocker.patch("ahriman.core.upload.rsync.Rsync.sync", side_effect=Exception) _, repository_id = configuration.check_loaded() with pytest.raises(SynchronizationError): diff --git a/tests/ahriman/models/test_package.py b/tests/ahriman/models/test_package.py index d72eec1e..6762302d 100644 --- a/tests/ahriman/models/test_package.py +++ b/tests/ahriman/models/test_package.py @@ -393,7 +393,7 @@ def test_actual_version_failed(package_tpacpi_bat_git: Package, configuration: C """ must return same version in case if exception occurred """ - mocker.patch("ahriman.core.build_tools.task.Task.init", side_effect=Exception()) + mocker.patch("ahriman.core.build_tools.task.Task.init", side_effect=Exception) mocker.patch("pathlib.Path.glob", return_value=[Path("local")]) unlink_mock = mocker.patch("pathlib.Path.unlink") diff --git a/tests/ahriman/models/test_package_source.py b/tests/ahriman/models/test_package_source.py index c5b7b8b1..25d62a6c 100644 --- a/tests/ahriman/models/test_package_source.py +++ b/tests/ahriman/models/test_package_source.py @@ -62,7 +62,7 @@ def test_resolve_aur_no_access(repository_paths: RepositoryPaths, mocker: Mocker """ must resolve auto type into the AUR package in case if we cannot read in suggested path """ - mocker.patch("pathlib.Path.is_dir", side_effect=PermissionError()) + mocker.patch("pathlib.Path.is_dir", side_effect=PermissionError) assert PackageSource.Auto.resolve("package", repository_paths) == PackageSource.AUR diff --git a/tests/ahriman/web/middlewares/test_exception_handler.py b/tests/ahriman/web/middlewares/test_exception_handler.py index 3ae807a6..ba061583 100644 --- a/tests/ahriman/web/middlewares/test_exception_handler.py +++ b/tests/ahriman/web/middlewares/test_exception_handler.py @@ -72,7 +72,7 @@ async def test_exception_handler_success(mocker: MockerFixture) -> None: must pass 2xx and 3xx codes """ request = pytest.helpers.request("", "", "") - request_handler = AsyncMock(side_effect=HTTPNoContent()) + request_handler = AsyncMock(side_effect=HTTPNoContent) logging_mock = mocker.patch("logging.Logger.exception") handler = exception_handler(logging.getLogger()) @@ -86,7 +86,7 @@ async def test_exception_handler_unauthorized(mocker: MockerFixture) -> None: must handle unauthorized exception as json response """ request = pytest.helpers.request("", "", "") - request_handler = AsyncMock(side_effect=HTTPUnauthorized()) + request_handler = AsyncMock(side_effect=HTTPUnauthorized) mocker.patch("ahriman.web.middlewares.exception_handler._is_templated_unauthorized", return_value=False) render_mock = mocker.patch("aiohttp_jinja2.render_template") @@ -101,7 +101,7 @@ async def test_exception_handler_unauthorized_templated(mocker: MockerFixture) - must handle unauthorized exception as json response in html context """ request = pytest.helpers.request("", "", "") - request_handler = AsyncMock(side_effect=HTTPUnauthorized()) + request_handler = AsyncMock(side_effect=HTTPUnauthorized) mocker.patch("ahriman.web.middlewares.exception_handler._is_templated_unauthorized", return_value=True) render_mock = mocker.patch("aiohttp_jinja2.render_template") @@ -154,7 +154,7 @@ async def test_exception_handler_client_error(mocker: MockerFixture) -> None: must handle client exception """ request = pytest.helpers.request("", "", "") - request_handler = AsyncMock(side_effect=HTTPBadRequest()) + request_handler = AsyncMock(side_effect=HTTPBadRequest) logging_mock = mocker.patch("logging.Logger.exception") handler = exception_handler(logging.getLogger()) @@ -168,7 +168,7 @@ async def test_exception_handler_server_error(mocker: MockerFixture) -> None: must handle server exception """ request = pytest.helpers.request("", "", "") - request_handler = AsyncMock(side_effect=HTTPInternalServerError()) + request_handler = AsyncMock(side_effect=HTTPInternalServerError) logging_mock = mocker.patch("logging.Logger.exception") handler = exception_handler(logging.getLogger()) diff --git a/tests/ahriman/web/test_web.py b/tests/ahriman/web/test_web.py index bee29e50..bbdc76a2 100644 --- a/tests/ahriman/web/test_web.py +++ b/tests/ahriman/web/test_web.py @@ -86,7 +86,7 @@ async def test_on_startup_exception(application: Application, watcher: Watcher, must throw exception on load error """ mocker.patch("aiohttp.web.Application.__getitem__", return_value={"": watcher}) - mocker.patch("ahriman.core.status.watcher.Watcher.load", side_effect=Exception()) + mocker.patch("ahriman.core.status.watcher.Watcher.load", side_effect=Exception) with pytest.raises(InitializeError): await _on_startup(application) diff --git a/tests/ahriman/web/views/v1/service/test_view_v1_service_pgp.py b/tests/ahriman/web/views/v1/service/test_view_v1_service_pgp.py index fd577a83..a10de795 100644 --- a/tests/ahriman/web/views/v1/service/test_view_v1_service_pgp.py +++ b/tests/ahriman/web/views/v1/service/test_view_v1_service_pgp.py @@ -60,7 +60,7 @@ async def test_get_process_exception(client: TestClient, mocker: MockerFixture) """ must raise 404 on invalid PGP server response """ - import_mock = mocker.patch("ahriman.core.sign.gpg.GPG.key_download", side_effect=Exception()) + import_mock = mocker.patch("ahriman.core.sign.gpg.GPG.key_download", side_effect=Exception) response_schema = pytest.helpers.schema_response(PGPView.get, code=400) response = await client.get("/api/v1/service/pgp", params={"key": "0xdeadbeaf", "server": "keyserver.ubuntu.com"}) diff --git a/tests/ahriman/web/views/v1/status/test_view_v1_status_status.py b/tests/ahriman/web/views/v1/status/test_view_v1_status_status.py index 76bea32d..e584e5ab 100644 --- a/tests/ahriman/web/views/v1/status/test_view_v1_status_status.py +++ b/tests/ahriman/web/views/v1/status/test_view_v1_status_status.py @@ -82,7 +82,7 @@ async def test_post_exception_inside(client: TestClient, mocker: MockerFixture) exception handler must handle 500 errors """ payload = {"status": BuildStatusEnum.Success.value} - mocker.patch("ahriman.core.status.watcher.Watcher.status_update", side_effect=Exception()) + mocker.patch("ahriman.core.status.watcher.Watcher.status_update", side_effect=Exception) response_schema = pytest.helpers.schema_response(StatusView.post, code=500) response = await client.post("/api/v1/status", json=payload) diff --git a/tests/ahriman/web/views/v1/user/test_view_v1_user_logout.py b/tests/ahriman/web/views/v1/user/test_view_v1_user_logout.py index 1a886ad3..fe4ec1a3 100644 --- a/tests/ahriman/web/views/v1/user/test_view_v1_user_logout.py +++ b/tests/ahriman/web/views/v1/user/test_view_v1_user_logout.py @@ -40,7 +40,7 @@ async def test_post_unauthorized(client_with_auth: TestClient, mocker: MockerFix """ must raise exception if unauthorized """ - mocker.patch("ahriman.web.views.v1.user.logout.check_authorized", side_effect=HTTPUnauthorized()) + mocker.patch("ahriman.web.views.v1.user.logout.check_authorized", side_effect=HTTPUnauthorized) forget_mock = mocker.patch("ahriman.web.views.v1.user.logout.forget") response_schema = pytest.helpers.schema_response(LogoutView.post, code=401)