test_ok2/changelog/3191.feature.rst

24 lines
592 B
ReStructuredText
Raw Normal View History

2018-12-06 02:14:41 +08:00
A warning is now issued when assertions are made for ``None``.
2018-10-31 03:15:03 +08:00
This is a common source of confusion among new users, which write:
2018-10-31 03:15:03 +08:00
.. code-block:: python
assert mocked_object.assert_called_with(3, 4, 5, key="value")
2018-10-31 03:15:03 +08:00
When they should write:
.. code-block:: python
mocked_object.assert_called_with(3, 4, 5, key="value")
2018-10-31 03:15:03 +08:00
Because the ``assert_called_with`` method of mock objects already executes an assertion.
This warning will not be issued when ``None`` is explicitly checked. An assertion like:
.. code-block:: python
2018-12-05 23:18:57 +08:00
assert variable is None
2018-12-06 02:14:41 +08:00
will not issue the warning.