jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1338953?usp=email )
Change subject: tests: Replace assertRaises with assertRaisesRegex
......................................................................
tests: Replace assertRaises with assertRaisesRegex
Strengthen exception assertions in setup and threading tests by
checking the expected error message.
Bug: T154281
Change-Id: I228074b4707f182f04aea7715ba54db08e5af01b
---
M AUTHORS.rst
M tests/setup_tests.py
M tests/tools_threading_tests.py
3 files changed, 9 insertions(+), 3 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/AUTHORS.rst b/AUTHORS.rst
index ab27905..00cea07 100644
--- a/AUTHORS.rst
+++ b/AUTHORS.rst
@@ -35,6 +35,7 @@
Anton
Aram
Avicennasis
+ Ayush Yadav
B
-
diff --git a/tests/setup_tests.py b/tests/setup_tests.py
index 7f62ef5..0570802 100755
--- a/tests/setup_tests.py
+++ b/tests/setup_tests.py
@@ -46,7 +46,9 @@
with patch.object(sys, 'argv', ['setup.py', 'sdist']):
with patch('builtins.print') as mock_print:
- with self.assertRaises(SystemExit):
+ with self.assertRaisesRegex(
+ SystemExit,
+ r'Build of distribution package canceled'):
setup.get_validated_version('pywikibot')
mock_print.assert_any_call(
diff --git a/tests/tools_threading_tests.py b/tests/tools_threading_tests.py
index 8ff2c70..a279cf9 100755
--- a/tests/tools_threading_tests.py
+++ b/tests/tools_threading_tests.py
@@ -191,7 +191,9 @@
pool = BoundedPoolExecutor(executor, max_bound=1,
max_workers=1)
pool.shutdown()
- with self.assertRaises(RuntimeError):
+ with self.assertRaisesRegex(
+ RuntimeError,
+ 'cannot schedule new futures after shutdown'):
pool.submit(pow, 2, 3)
self.assertTrue(
pool._bound_semaphore.acquire(blocking=False)
@@ -207,7 +209,8 @@
failure = error('submission failed')
with patch.object(ThreadPoolExecutor, 'submit',
side_effect=failure):
- with self.assertRaises(error) as caught:
+ with self.assertRaisesRegex(
+ error, 'submission failed') as caught:
pool.submit(pow, 2, 3)
self.assertIs(caught.exception, failure)
self.assertTrue(
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1338953?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I228074b4707f182f04aea7715ba54db08e5af01b
Gerrit-Change-Number: 1338953
Gerrit-PatchSet: 1
Gerrit-Owner: Ayush8620 <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]