Page MenuHomePhabricator

replace assertRaises/assertWarns partial calls with context manager calls
Closed, ResolvedPublic

Description

What to change?

All occurences of

  • assertRaises
  • assertRaisesRegex
  • assertWarns
  • assertWarnsRegex

They can be found here.

Why to change?

These unittest methods were changed from partial call to context manager with the benefit of better readability and a new msg parameter which is provided with it

How to change?

replace code like

self.assertRaisesRegex(ValueError, "invalid literal for.*XYZ'$", int, 'XYZ')

with

with self.assertRaisesRegex(ValueError, "invalid literal for.*XYZ'$"):
   int('XYZ')

Documentation

https://docs.python.org/3/library/unittest.html?highlight=assertraisesregex#unittest.TestCase.assertRaises

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald Transcript
Xqt triaged this task as Lowest priority.Nov 12 2020, 2:49 PM
Xqt updated the task description. (Show Details)

Change 642172 had a related patch set uploaded (by Udoka; owner: Udoka):
[pywikibot/core@master] [IMPR] Replaced assertRaises/assertWarns partial calls with context manager calls

https://gerrit.wikimedia.org/r/642172

Change 642173 had a related patch set uploaded (by Udoka; owner: Udoka):
[pywikibot/core@master] [IMPR] Replaced assertRaises/assertWarns partial calls with context manager calls

https://gerrit.wikimedia.org/r/642173

Change 642174 had a related patch set uploaded (by Udoka; owner: Udoka):
[pywikibot/core@master] [IMPR] Replaced assertRaises/assertWarns partial calls

https://gerrit.wikimedia.org/r/642174

Change 642174 abandoned by Xqt:
[pywikibot/core@master] [IMPR] Replaced assertRaises/assertWarns partial calls

Reason:
2 months without any change

https://gerrit.wikimedia.org/r/642174

Change 642173 abandoned by Xqt:
[pywikibot/core@master] [IMPR] Replaced assertRaises/assertWarns partial calls with context manager calls

Reason:
2 months without any change

https://gerrit.wikimedia.org/r/642173

Change 642172 abandoned by Xqt:
[pywikibot/core@master] [IMPR] Replaced assertRaises/assertWarns partial calls with context manager calls

Reason:
2 months without any change

https://gerrit.wikimedia.org/r/642172

Xqt removed a project: Patch-For-Review.
Xqt added a subscriber: Udoka_Ugo.

Change 657287 had a related patch set uploaded (by Homeboy 445; owner: Homeboy 445):
[pywikibot/core@master] Adopted context Manager call for assertRaises in certain script(s)

https://gerrit.wikimedia.org/r/657287

Change 657287 merged by jenkins-bot:
[pywikibot/core@master] Adopted context Manager call for assertRaises in certain script(s)

https://gerrit.wikimedia.org/r/657287

Change 657863 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [tests] Fix assertRaises tests in api_tests.py

https://gerrit.wikimedia.org/r/657863

Change 657863 merged by Xqt:
[pywikibot/core@master] [tests] Fix assertRaises tests in api_tests.py

https://gerrit.wikimedia.org/r/657863

Change 658222 had a related patch set uploaded (by Homeboy 445; owner: Homeboy 445):
[pywikibot/core@master] Adopted use of Context Manager call for assertRaises/assertRaisesRegex in certain scripts

https://gerrit.wikimedia.org/r/658222

Change 658222 merged by jenkins-bot:
[pywikibot/core@master] Adopted use of Context Manager call for assertRaises/assertRaisesRegex

https://gerrit.wikimedia.org/r/658222

Xqt removed a project: Patch-For-Review.
Xqt added a subscriber: Homeboy_445.

Change 659857 had a related patch set uploaded (by Homeboy 445; owner: Homeboy 445):
[pywikibot/core@master] Adopted context manager calls for assertRaises/assertRaisesRegex

https://gerrit.wikimedia.org/r/659857

Change 659857 merged by jenkins-bot:
[pywikibot/core@master] Adopted context manager calls for assertRaises/assertRaisesRegex

https://gerrit.wikimedia.org/r/659857

Change 661124 had a related patch set uploaded (by Homeboy 445; owner: Homeboy 445):
[pywikibot/core@master] Used Context Manager call for assertRaises/assertRaisesRegex

https://gerrit.wikimedia.org/r/661124

Change 661124 merged by jenkins-bot:
[pywikibot/core@master] Used Context Manager call for assertRaises/assertRaisesRegex

https://gerrit.wikimedia.org/r/661124

Change 662107 had a related patch set uploaded (by Homeboy 445; owner: Homeboy 445):
[pywikibot/core@master] Adopted use of context Manager call for assertRaises/assertRaisesRegex

https://gerrit.wikimedia.org/r/662107

Change 662107 merged by jenkins-bot:
[pywikibot/core@master] Adopted use of context Manager call for assertRaises/assertRaisesRegex

https://gerrit.wikimedia.org/r/662107

Xqt removed a project: Patch-For-Review.

Thank you Homeboy_445!