Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assertRaises callableObj cannot be used as a keyword with args #70798

Closed
ChrisMitchell mannequin opened this issue Mar 22, 2016 · 2 comments
Closed

assertRaises callableObj cannot be used as a keyword with args #70798

ChrisMitchell mannequin opened this issue Mar 22, 2016 · 2 comments
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@ChrisMitchell
Copy link
Mannequin

ChrisMitchell mannequin commented Mar 22, 2016

BPO 26611

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2016-03-22.13:51:27.290>
created_at = <Date 2016-03-22.13:38:21.243>
labels = ['invalid', 'type-bug', 'tests']
title = 'assertRaises callableObj cannot be used as a keyword with args'
updated_at = <Date 2016-03-22.13:51:27.288>
user = 'https://bugs.python.org/ChrisMitchell'

bugs.python.org fields:

activity = <Date 2016-03-22.13:51:27.288>
actor = 'SilentGhost'
assignee = 'none'
closed = True
closed_date = <Date 2016-03-22.13:51:27.290>
closer = 'SilentGhost'
components = ['Tests']
creation = <Date 2016-03-22.13:38:21.243>
creator = 'Chris Mitchell'
dependencies = []
files = []
hgrepos = []
issue_num = 26611
keywords = []
message_count = 2.0
messages = ['262183', '262184']
nosy_count = 2.0
nosy_names = ['SilentGhost', 'Chris Mitchell']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue26611'
versions = ['Python 2.7']

@ChrisMitchell
Copy link
Mannequin Author

ChrisMitchell mannequin commented Mar 22, 2016

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.

@ChrisMitchell ChrisMitchell mannequin added type-crash A hard crash of the interpreter, possibly with a core dump tests Tests in the Lib/test dir labels Mar 22, 2016
@SilentGhost
Copy link
Mannequin

SilentGhost mannequin commented Mar 22, 2016

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

@SilentGhost SilentGhost mannequin closed this as completed Mar 22, 2016
@SilentGhost SilentGhost mannequin added invalid type-bug An unexpected behavior, bug, or error and removed type-crash A hard crash of the interpreter, possibly with a core dump labels Mar 22, 2016
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

0 participants