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.
Created on 2012年06月17日 15:39 by markon, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (2) | |||
|---|---|---|---|
| msg163072 - (view) | Author: Marco Buccini (markon) | Date: 2012年06月17日 15:39 | |
Suppose that you have an instance method that takes 2 arguments: one is required, while the other is a keyword argument. If you call that method without passing the required argument, but instead you only set the keyword argument, then you will get a TypeError exception, claiming this ... -> TypeError: 'method' takes at least 2 arguments (2 given) (I am referring to this particular method: http://www.voidspace.org.uk/python/mock/mock.html#mock.Mock.mock_add_spec) @patch('xyz.subprocess.Popen') def test_xyz(self, mocked_popen): mocked_popen.mock_add_spec(spec_set=True) I think the right error message should be different, in particular should be this: -> TypeError: 'method' takes at least 2 arguments (1 given) |
|||
| msg163073 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2012年06月17日 15:43 | |
This is fixed in Python3: >>> def foo(a, b=None): ... pass ... >>> foo(b=1) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: foo() missing 1 required positional argument: 'a' |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:31 | admin | set | github: 59303 |
| 2012年06月17日 15:43:49 | r.david.murray | set | status: open -> closed nosy: + r.david.murray messages: + msg163073 resolution: out of date stage: resolved |
| 2012年06月17日 15:39:27 | markon | create | |