From 6e1ce5483082687c8fd95e434a68f7cdab0d3c6b Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 17 2020 14:26:51 +0000 Subject: Only patch PDCClient when it's installed The code can cope with PDCClient not being installed but the tests did not. With this commit, the tests only patch PDCClient if it is installed thus allowing both the code and the tests to cope with this library being missing. Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure_distgit_tests/dist_git_auth_tests.py b/pagure_distgit_tests/dist_git_auth_tests.py index 0b6825e..965ba0b 100644 --- a/pagure_distgit_tests/dist_git_auth_tests.py +++ b/pagure_distgit_tests/dist_git_auth_tests.py @@ -55,13 +55,14 @@ def patch_pdc(values): def decorator(func): def test_wrapper(*args, **kwargs): - with patch.object(dist_git_auth.PDCClient, "__getitem__"): - with patch.object( - dist_git_auth.PDCClient, - "get_paged", - side_effect=pdc_get_paged, - ): - return func(*args, **kwargs) + if dist_git_auth.PDCClient: + with patch.object(dist_git_auth.PDCClient, "__getitem__"): + with patch.object( + dist_git_auth.PDCClient, + "get_paged", + side_effect=pdc_get_paged, + ): + return func(*args, **kwargs) return test_wrapper