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)
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')
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 and docs directories are now distributed with the source tarball. See GH-20.
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.
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.