You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inappropriateness in unittest documentation with actual behavior #118912
Your tests can pass silently and incorrectly because of the typo.
Expected that tests will pass as written in doc.
But actually script fails with raising error.
raise AttributeError(
AttributeError: 'assret_called_once_with' is not a valid assertion. Use a spec for the mock if 'assret_called_once_with' is meant to be an attribute.. Did you mean: 'assert_called_once_with'?
Am i missing something? I have tested this in Python3.11 and Python 3.12.
Looks like documentation must be updated or script must work as said in documenation.
:exc:`AttributeError`. Passing ``unsafe=True`` will allow access to
unsafe: By default, accessing any attribute whose name starts with assert, assret, asert, aseert or assrt will raise an AttributeError. Passing unsafe=True will allow access to these attributes.
Activity
blhsing commentedon May 16, 2024
Note that the doc describes the pre-Python 3.5 behavior. Since Python 3.5, one has to enable the
unsafeoption to achieve the same behavior:cpython/Doc/library/unittest.mock.rst
Line 269 in c444362
shaunagm commentedon May 20, 2024
I am working on this issue! I hope to finish it today (at the PyCon sprints)
gh-118912: Remove description of issue fixed in 3.5 from autospeccing…
pythongh-118912: Remove description of issue fixed in 3.5 from autosp…
pythongh-118912: Remove description of issue fixed in 3.5 from autosp…
[3.12] gh-118912: Remove description of issue fixed in 3.5 from autos…
[3.13] gh-118912: Remove description of issue fixed in 3.5 from autos…
pythongh-118912: Remove description of issue fixed in 3.5 from autosp…