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年09月04日 13:06 by Julian, last changed 2022年04月11日 14:57 by admin.
| Messages (4) | |||
|---|---|---|---|
| msg169826 - (view) | Author: Julian Berman (Julian) * | Date: 2012年09月04日 13:06 | |
Mock's assertion failures can be extremely hard to read for a few reasons -- mostly the noisy default repr that mock objects have, but also because they don't give you the hints that `unittest.TestCase`'s `assert*` methods give you (things like diffing two lists for example). unittest.mock.Mock's `assert*` methods could hook into the TestCase's assertion methods if Mock either gained a MockInTestCase subclass or started taking an arg to `__init__` that was an instance of `TestCase`, so that `assert*` could then use the assertion methods on the instance. #11664 could (should) then obviously use this argument by default when patching. Another added advantage would be that the raised exception could then be `TestCase.failureException`, whatever that might be, rather than `AssertionError`, though I doubt that's that big a deal since that's usually a subclass of `AssertionError` I bet. |
|||
| msg170303 - (view) | Author: Michael Foord (michael.foord) * (Python committer) | Date: 2012年09月11日 13:15 | |
Yep, interesting idea. In Python 3 you can't import unittest.mock without importing unittest, so there could even be a "default testcase" to fall back on. For the external release I'd rather not have unittest as a dependency, but allowing a testcase to be provided at instantiation would be fine. |
|||
| msg170304 - (view) | Author: Michael Foord (michael.foord) * (Python committer) | Date: 2012年09月11日 13:15 | |
The only issue is that the testcase would have to be propagated to child mocks too. |
|||
| msg381330 - (view) | Author: Karthikeyan Singaravelan (xtreak) * (Python committer) | Date: 2020年11月18日 12:25 | |
See also https://bugs.python.org/issue28054 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:35 | admin | set | github: 60064 |
| 2020年11月18日 12:25:52 | xtreak | set | nosy:
+ xtreak messages: + msg381330 |
| 2020年11月18日 11:46:59 | iritkatriel | set | type: enhancement versions: + Python 3.9, Python 3.10, - Python 3.4 |
| 2012年09月11日 15:00:36 | eric.araujo | set | nosy:
+ eric.araujo versions: - Python 3.3 |
| 2012年09月11日 13:15:37 | michael.foord | set | messages: + msg170304 |
| 2012年09月11日 13:15:13 | michael.foord | set | assignee: michael.foord messages: + msg170303 |
| 2012年09月04日 13:16:47 | ezio.melotti | set | nosy:
+ ezio.melotti |
| 2012年09月04日 13:06:59 | Julian | create | |