This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: assertRaises callableObj cannot be used as a keyword with args
Type: behavior Stage: resolved
Components: Tests Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Chris Mitchell, SilentGhost
Priority: normal Keywords:

Created on 2016-03-22 13:38 by Chris Mitchell, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg262183 - (view) Author: Chris Mitchell (Chris Mitchell) Date: 2016-03-22 13:38
assertRaises has callableObj listed as a keyword, though it is not possible to use it as a keyword when the callableObj takes arguments. 

The function definition is:
    def assertRaises(self, excClass, callableObj=None, *args, **kwargs):

Therefore, using it with a keyword such as:

    self.assertRaises(Exception, callableObj=my_function, args_to_function)

will fail due to passing arguments after a keyword.
msg262184 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2016-03-22 13:51
Documentation [0] has callable listed as a positional argument, and this is how it should be used.

[0] https://docs.python.org/2.7/library/unittest.html#unittest.TestCase.assertRaises
History
Date User Action Args
2022-04-11 14:58:28adminsetgithub: 70798
2016-03-22 13:51:27SilentGhostsetstatus: open -> closed

type: crash -> behavior

nosy: + SilentGhost
messages: + msg262184
resolution: not a bug
stage: resolved
2016-03-22 13:38:21Chris Mitchellcreate