Expects

Latest version: v0.9.0

Safety actively analyzes 629811 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 2 of 4

0.8.0rc1

---------------------

Highlights
^^^^^^^^^^

* New failure messages for matchers. Now its easier to see the reason that caused the assertion failure. For example::

>>> expect([1, {'foo': 1}]).to(contain(have_key('foo', 2)))

AssertionError:
expected: [1, {'foo': 1}] to contain have key 'foo' equal 2
but: item have key 'foo' equal 2 not found

Bug fixes
^^^^^^^^^

* Now the failure message for ``have_key``/``have_keys`` is fixed when composed with another matcher. See `GH-29 <https://github.com/jaimegildesagredo/expects/issues/29>`_.

Backwards-incompatible
^^^^^^^^^^^^^^^^^^^^^^

Although your assertions should still be working (if are broken, just `report an issue <https://github.com/jaimegildesagredo/expects/issues>`_), the *custom matchers* api has been changed. To see an example of how to migrate your custom matchers to the new api you can see `the doublex-expects migration <https://github.com/jaimegildesagredo/doublex-expects/commit/f4908989298fbbaed46b59080d3a619a37f533fa>`_.

* The ``Matcher._match`` method now should return a tuple of ``bool`` representing the result of the matcher and a ``list`` of reasons that explain this result::

def _match(self, subject):
if subject:
return True, ['a reason']
return False, ['another reason']

* The ``Matcher._description`` method was removed. Now, with the change announced above, a matcher description won't need the subject to describe itself, so the ``__repr__`` magic method will be used instead to describe matchers.

* The ``Matcher._match_value`` method was removed. With the new api it made much less sense so it was removed and the ``expects.matchers.default_matcher`` wrapper function was added::

>>> default_matcher(1)._match(2)
False, ['was 1']

0.7.1

------------------

Bug fixes
^^^^^^^^^

* The ``contain_exactly`` matcher does not raise an ``IndexError`` if the subject list has fewer elements than the expected one. `GH-23 <https://github.com/jaimegildesagredo/expects/issues/23>`_.

0.7.0

------------------

Highlights
^^^^^^^^^^

* Added ``have_len`` as an alias to ``have_length``.
* The ``have_len`` and ``have_length`` matchers can receive another matcher as expected value::

expect('foo').to(have_len(be_above(2)))

* The ``contain`` and ``contain_exactly`` matchers now can receive another matchers as arguments::

expect(['foo', 'bar']).to(contain(be_a(str)))
expect(['foo', 'bar']).to(contain_exactly(be_a(str), match('\w+')))

* Improved ``be_a`` and ``be_an`` failure messages.
* Added the ``contain_only`` matcher::

expect([1, 2]).to(contain_only(2, 1))

* Added the ``to_not`` alias for ``not_to`` to negate assertions::

expect(True).to_not(be_false)

* Added the `aliases <http://expects.readthedocs.org/en/latest/aliases.html>`_ module with matcher aliases useful to compose matchers::

from expects import *
from expects.aliases import *

expect([1, 2]).to(contain_exactly(an(int), 2))

Backwards-incompatible
^^^^^^^^^^^^^^^^^^^^^^

* The ``failure`` context manager now uses the ``end_with`` matcher as default matcher for failure message instead of the previously used ``contain`` matcher. Example::

>>> from expects.testing import failure
>>> with failure('foo'):
... raise AssertionError('A foo message')
AssertionError: Expected message 'A foo message' to end with 'foo'

>>> with failure('message'):
... raise AssertionError('A foo message')

0.6.2

------------------

Bug fixes
^^^^^^^^^

* Fixed ``contain_exactly`` to work with iterable objects. Regression introduced in v0.6.1.

0.6.1

------------------

Bug fixes
^^^^^^^^^

* Now the ``contain`` and ``contain_exactly`` matchers fail with a proper message when used with a non-sequence type. See `GH-21 <https://github.com/jaimegildesagredo/expects/issues/21>`_.

0.6.0

------------------

Highlights
^^^^^^^^^^

* Now the ``raise_error`` matcher can be used without specifying an exception class for writing less strict assertions::

expect(lambda: foo).to(raise_error)

* Implemented the ``Matcher._match_value`` method to help develop custom matchers that receive another matchers. See the `docs <http://expects.readthedocs.org/en/latest/custom-matchers.htmlexpects.matchers.Matcher._match_value>`_ for more info.

* The ``specs`` and ``docs`` directories are now distributed with the source tarball. See `GH-20 <https://github.com/jaimegildesagredo/expects/pull/20>`_.

Page 2 of 4

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.