Changes
0.9.0 (2018-10-25)
Highlights
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_keysis fixed when composed with another matcher. See GH-29.Allow
contain,contain_exactlyandcontain_onlymatchers to work with dict views (e.g.dict.keys()). See GH-42.Allow
contain,contain_exactlyandcontain_onlymatchers to work with sets. See GH-38.Show traceback in
raise_errorwhen another exception is raised. See GH-41.The
equalmatcher now uses__ne__for negated assertions. See GH-40.The
not_matcher now uses the inner matcher_match_negatedmethod 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._matchmethod now should return a tuple ofboolrepresenting the result of the matcher and alistof reasons that explain this result:def _match(self, subject): if subject: return True, ['a reason'] return False, ['another reason']
The
Matcher._descriptionmethod 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_valuemethod was removed. With the new api it made much less sense so it was removed and theexpects.matchers.default_matcherwrapper function was added:>>> default_matcher(1)._match(2) False, ['was 1']
0.8.0rc5 (2016-05-07)
Bug fixes
0.8.0rc4 (2015-10-14)
Bug fixes
Show the correct failure message on negated
contain_exactlyandcontain_onlymatchers. See GH-33.
0.8.0rc3 (2015-10-07)
Bug fixes
The
equalmatcher now uses__ne__for negated assertions. See GH-40.The
not_matcher now uses the inner matcher_match_negatedmethod to perform a negated assertion.
0.8.0rc2 (2015-08-14)
Bug fixes
Python 2.6 support.
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_keysis 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._matchmethod now should return a tuple ofboolrepresenting the result of the matcher and alistof reasons that explain this result:def _match(self, subject): if subject: return True, ['a reason'] return False, ['another reason']
The
Matcher._descriptionmethod 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_valuemethod was removed. With the new api it made much less sense so it was removed and theexpects.matchers.default_matcherwrapper function was added:>>> default_matcher(1)._match(2) False, ['was 1']
0.7.0 (2015-06-26)
Bug fixes
Bug fixes
The
contain_exactlymatcher does not raise anIndexErrorif the subject list has fewer elements than the expected one. GH-23.
0.7.1 (2015-06-09)
Bug fixes
The
contain_exactlymatcher does not raise anIndexErrorif the subject list has fewer elements than the expected one. GH-23.
0.7.0 (2015-03-01)
Highlights
Added
have_lenas an alias tohave_length.The
have_lenandhave_lengthmatchers can receive another matcher as expected value:expect('foo').to(have_len(be_above(2)))
The
containandcontain_exactlymatchers 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_aandbe_anfailure messages.Added the
contain_onlymatcher:expect([1, 2]).to(contain_only(2, 1))
Added the
to_notalias fornot_toto 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
failurecontext manager now uses theend_withmatcher as default matcher for failure message instead of the previously usedcontainmatcher. 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_exactlyto work with iterable objects. Regression introduced in v0.6.1.
0.6.1 (2014-11-30)
Bug fixes
Now the
containandcontain_exactlymatchers fail with a proper message when used with a non-sequence type. See GH-21.
0.6.0 (2014-11-24)
Highlights
Now the
raise_errormatcher can be used without specifying an exception class for writing less strict assertions:expect(lambda: foo).to(raise_error)
Implemented the
Matcher._match_valuemethod to help develop custom matchers that receive another matchers. See the docs for more info.The
specsanddocsdirectories 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.failurecontext 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_callablematcher.Published a list of 3rd Party Matchers libraries.
Bug fixes
The
be_withinmatcher now supports float values.In some places
byteswere not being treated as a string type in python 3.
Backwards-incompatible
The
matchmatcher 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.failurecontext manager not longer tries to match regular expressions. Instead you can pass thematchmatcher 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 theexpectcallable 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_keysandhave_propertiesmatchers.The
raise_errormatcher now can receive any other matcher as the second argument.
Bug fixes
The
have_keyandhave_keysalways fail if the subject is not a dict.Fixed
containmatcher behavior when negated. See this commit.
Backwards-incompatible
The
end_withmatcher should receive args in the right order and not reversed. See this commit.The
to.haveandto.have.onlyassertions have been remamed tocontainandcontain_exactlymatchers.Assertion chaining has been replaced by matcher composition in all places where was possible in the previous version.
The
testing.failurecontext 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.
Bug fixes
Fixes a regression in the
raise_errorassertion introduced in v0.2.2 which caused some tests to fail. See GH-17 for more info.
0.2.3 (2014-06-04)
Highlights
Added the start_with and end_with assertions. GH-14.
0.2.2 (2014-05-20)
Bug fixes
to.raise_error now works with a non-string object as second arg. See docs for examples.
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
keyandpropertyexpectations now return a newExpectsobject 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.emptyis the same thanexpect('foo').to.not_be.empty.Added the
only.haveexpectation to test that the subject only has the given items.
Backwards-incompatible
The
greater_than,greater_or_equal_to,less_thanandless_or_equal_toexpectations are renamed toabove,above_or_equal,belowandbelow_or_equal.
0.1.1 (2013-08-20)
Bug fixes
0.1.0 (2013-08-11)
Highlights
First expects release.