Changes¶
0.9.0 (2018-10-25)¶
Highlights¶
- Fix Python 3.7 collections ABC classes deprecation warning. See GH-55 <https://github.com/jaimegildesagredo/expects/pull/55>.
- Hide
expects
internals from pytest tracebacks. See GH-51 <https://github.com/jaimegildesagredo/expects/pull/51>.
Backwards-incompatible¶
- Dropped Python 2.6 support.
0.8.0 (2016-05-15)¶
Changes since last stable release:
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. - Allow
contain
,contain_exactly
andcontain_only
matchers to work with dict views (e.g.dict.keys()
). See GH-42. - Allow
contain
,contain_exactly
andcontain_only
matchers to work with sets. See GH-38. - Show traceback in
raise_error
when another exception is raised. See GH-41. - The
equal
matcher now uses__ne__
for negated assertions. See GH-40. - The
not_
matcher now uses the inner matcher_match_negated
method to perform a negated assertion. - Python 2.6 support.
Backwards-incompatible¶
Although your assertions should still be working (if are broken, just report an issue), 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.
The
Matcher._match
method now should return a tuple ofbool
representing the result of the matcher and alist
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 theexpects.matchers.default_matcher
wrapper function was added:>>> default_matcher(1)._match(2) False, ['was 1']
0.8.0rc5 (2016-05-07)¶
0.8.0rc4 (2015-10-14)¶
0.8.0rc3 (2015-10-07)¶
0.8.0rc1 (2015-07-17)¶
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.
Backwards-incompatible¶
Although your assertions should still be working (if are broken, just report an issue), 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.
The
Matcher._match
method now should return a tuple ofbool
representing the result of the matcher and alist
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 theexpects.matchers.default_matcher
wrapper function was added:>>> default_matcher(1)._match(2) False, ['was 1']
0.7.0 (2015-06-26)¶
0.7.1 (2015-06-09)¶
0.7.0 (2015-03-01)¶
Highlights¶
Added
have_len
as an alias tohave_length
.The
have_len
andhave_length
matchers can receive another matcher as expected value:expect('foo').to(have_len(be_above(2)))
The
contain
andcontain_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
andbe_an
failure messages.Added the
contain_only
matcher:expect([1, 2]).to(contain_only(2, 1))
Added the
to_not
alias fornot_to
to negate assertions:expect(True).to_not(be_false)
Added the aliases 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 theend_with
matcher as default matcher for failure message instead of the previously usedcontain
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 (2014-12-10)¶
Bug fixes¶
- Fixed
contain_exactly
to work with iterable objects. Regression introduced in v0.6.1.
0.6.1 (2014-11-30)¶
0.6.0 (2014-11-24)¶
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 for more info.The
specs
anddocs
directories are now distributed with the source tarball. See GH-20.
0.5.0 (2014-09-20)¶
Highlights¶
Now the
&
and|
operators can be used to write simpler assertions:expect('Foo').to(have_length(3) & start_with('F')) expect('Foo').to(equal('Foo') | equal('Bar'))
The
testing.failure
context manager can be used even without calling it with the failure message as argument:with failure: expect('foo').to(be_empty)
Also can receive matchers as argument:
with failure(end_with('empty')): expect('foo').to(be_empty)
Note
See also backwards-incompatible changes for testing.failure
.
- Added the
be_callable
matcher. - Published a list of 3rd Party Matchers libraries.
Bug fixes¶
- The
be_within
matcher now supports float values. - In some places
bytes
were not being treated as a string type in python 3.
Backwards-incompatible¶
- The
match
matcher now passes if matches a part of the subject string instead of all of it. Previously used there.match()
and now usesre.search()
. If your tests depended on this you can migrate them by adding a'^'
and'$'
at the beginning and end of your regular expression. - The
testing.failure
context manager not longer tries to match regular expressions. Instead you can pass thematch
matcher with your regexp.
0.4.2 (2014-08-16)¶
Highlights¶
- Added the
not_
matcher to negate another matcher when composing matchers.
0.4.1 (2014-08-16)¶
Bug fixes¶
- Now
from expects import *
only imports theexpect
callable and built in matchers.
0.4.0 (2014-08-15)¶
Warnings¶
This release does not maintain backwards compatibility with the previous version because a new syntax was implemented based on matchers. Matchers have been implemented maintaining compatibility with its equivalent assertions (and those that break compatibility are listed below). For most users upgrade to this version will only involve a migration to the new syntax.
Highlights¶
- Improved failure message for
have_keys
andhave_properties
matchers. - The
raise_error
matcher now can receive any other matcher as the second argument.
Bug fixes¶
- The
have_key
andhave_keys
always fail if the subject is not a dict. - Fixed
contain
matcher behavior when negated. See this commit.
Backwards-incompatible¶
- The
end_with
matcher should receive args in the right order and not reversed. See this commit. - The
to.have
andto.have.only
assertions have been remamed tocontain
andcontain_exactly
matchers. - Assertion chaining has been replaced by matcher composition in all places where was possible in the previous version.
- The
testing.failure
context manager now only receives a string matching the failure message.
0.3.0 (2014-06-29)¶
Highlights¶
- The start_with and end_with assertions now support lists, iterators and ordered dicts. GH-16.
0.2.3 (2014-06-04)¶
Highlights¶
- Added the start_with and end_with assertions. GH-14.
0.2.2 (2014-05-20)¶
0.2.1 (2014-03-22)¶
Highlights¶
- Added a testing module with the failure contextmanager.
- Added a matchers module and the key matcher.
Bug fixes¶
- to.have and to.only.have now work properly when actual is a string.
0.2.0 (2014-02-05)¶
Highlights¶
- Added initial plugins support. See plugins docs for more info.
- The
key
andproperty
expectations now return a newExpects
object that can be used to chain expectations. - Now every expectation part can be prefixed with
not_
in order to negate an expectation. Ex:expect('foo').not_to.be.empty
is the same thanexpect('foo').to.not_be.empty
. - Added the
only.have
expectation to test that the subject only has the given items.
Backwards-incompatible¶
- The
greater_than
,greater_or_equal_to
,less_than
andless_or_equal_to
expectations are renamed toabove
,above_or_equal
,below
andbelow_or_equal
.