From 81a252d82dee9fd396ee8e0eb07a4b4c1f93c11d Mon Sep 17 00:00:00 2001 From: AntiCompositeNumber Date: Tue, 17 Aug 2021 17:51:38 -0400 Subject: [PATCH] replace deprecated pywikibot exceptions --- src/tests/test_nolicense.py | 5 ++++- src/utils.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tests/test_nolicense.py b/src/tests/test_nolicense.py index 091bce0..7162e6d 100644 --- a/src/tests/test_nolicense.py +++ b/src/tests/test_nolicense.py @@ -273,7 +273,10 @@ def test_warn_user_conflict(): ) user_talk = mock.Mock(title=mock.Mock(return_value="user_talk"), text="old_text()") user_talk.get.side_effect = [user_talk.text, "new_old_text()"] - user_talk.save.side_effect = [pywikibot.exceptions.EditConflict(user_talk), None] + user_talk.save.side_effect = [ + pywikibot.exceptions.EditConflictError(user_talk), + None, + ] with mock.patch.dict("nolicense.config", test_config): nolicense.warn_user( user_talk=user_talk, diff --git a/src/utils.py b/src/utils.py index 1172c13..854e324 100644 --- a/src/utils.py +++ b/src/utils.py @@ -175,7 +175,7 @@ def save_page( elif mode == "append": try: text = page.get(force=True) + text - except pywikibot.exceptions.NoPage as err: + except pywikibot.exceptions.NoPageError as err: logger.exception(err) if new_ok: text = text @@ -184,7 +184,7 @@ def save_page( elif mode == "prepend": try: text = text + page.get(force=True) - except pywikibot.exceptions.NoPage as err: + except pywikibot.exceptions.NoPageError as err: logger.exception(err) if new_ok: text = text