-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from sgissinger/master
RST update: fixes #57, splitted operator page, added mock operators, other doc refactor
- Loading branch information
Showing
11 changed files
with
961 additions
and
994 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
Accessors Operators | ||
=================== | ||
|
||
These operators do not accept expectation arguments but performs assertion logic. | ||
|
||
Example operators: none_, true_, false_, empty_, callable_ ... | ||
|
||
|
||
true | ||
---- | ||
|
||
Asserts if a given subject is `True` value. | ||
|
||
======================= ======================== | ||
**Related operators** false_ | ||
======================= ======================== | ||
|
||
.. code-block:: python | ||
'foo' | should.be.true | ||
'foo' | should.not_be.true | ||
.. code-block:: python | ||
expect('foo').to.be.true | ||
expect('foo').to_not.be.true | ||
false | ||
----- | ||
|
||
Asserts if a given subject is `False` value. | ||
|
||
======================= ======================== | ||
**Related operators** true_ | ||
======================= ======================== | ||
|
||
.. code-block:: python | ||
'foo' | should.be.false | ||
'foo' | should.not_be.false | ||
.. code-block:: python | ||
expect('foo').to.be.false | ||
expect('foo').to_not.be.false | ||
callable | ||
-------- | ||
|
||
Asserts if a given subject is a callable type or an object that | ||
implements ``__call__()`` magic method. | ||
|
||
======================= ======================== | ||
**Related operators** implements_ | ||
======================= ======================== | ||
|
||
.. code-block:: python | ||
(lambda x: x) | should.be.callable | ||
None | should.not_be.callable | ||
.. code-block:: python | ||
expect(lambda x: x).to.be.callable | ||
expect(None).to_not.be.callable | ||
empty | ||
----- | ||
|
||
Asserts if a given subject is an empty object. | ||
|
||
A subject is considered empty if it's ``None``, ``0`` or ``len(subject)`` | ||
is equals to ``0``. | ||
|
||
======================= ======================== | ||
**Related operators** present_ none_ | ||
======================= ======================== | ||
|
||
.. code-block:: python | ||
[] | should.be.empty | ||
[1, 2, 3] | should.not_be.empty | ||
.. code-block:: python | ||
expect(tuple()).to.be.empty | ||
expect((1, 2, 3)).to_not.be.empty | ||
none | ||
---- | ||
|
||
Asserts if a given subject is ``None``. | ||
|
||
======================= ======================== | ||
**Related operators** present_ empty_ | ||
======================= ======================== | ||
|
||
.. code-block:: python | ||
None | should.be.none | ||
'foo' | should.not_be.none | ||
.. code-block:: python | ||
expect(None).to.be.none | ||
expect('foo').to_not.be.none | ||
exists | ||
------ | ||
present | ||
------- | ||
|
||
Asserts if a given subject is not ``None`` or a negative value | ||
if evaluated via logical unary operator. | ||
|
||
This operator is the opposite of empty_. | ||
|
||
======================= ======================== | ||
**Related operators** none_ empty_ | ||
======================= ======================== | ||
|
||
.. code-block:: python | ||
'foo' | should.be.present | ||
'' | should.not_be.present | ||
.. code-block:: python | ||
expect('foo').to.be.present | ||
expect(False).to_not.be.present | ||
.. _`implements`: http://grappa.readthedocs.io/en/latest/matchers-operators.html#implements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
Attributes Operators | ||
==================== | ||
|
||
These operators provides assertion/negation logic. | ||
|
||
Example operators: to_, be_ not_be_, which_ ... | ||
|
||
|
||
Assertion | ||
--------- | ||
|
||
be | ||
^^ | ||
to | ||
^^ | ||
has | ||
^^^ | ||
have | ||
^^^^ | ||
do | ||
^^ | ||
include | ||
^^^^^^^ | ||
satisfy | ||
^^^^^^^ | ||
satisfies | ||
^^^^^^^^^ | ||
_is | ||
^^^ | ||
which | ||
^^^^^ | ||
that | ||
^^^^ | ||
that_is | ||
^^^^^^^ | ||
which_is | ||
^^^^^^^^ | ||
|
||
Semantic chainable attributes that defines non-negative assertions. | ||
|
||
Typically, you will use them implicitly in order to semantically describe your assertions. | ||
|
||
======================= ======================== | ||
**Assertion mode** positive | ||
----------------------- ------------------------ | ||
**Resets context** no | ||
======================= ======================== | ||
|
||
.. code-block:: python | ||
'foo' | should.be.equal.to('bar') | ||
'foo' | should.have.length.of(3) | ||
{'foo': 'bar'} | should.have.key('foo').which.should.be.equal.to('bar') | ||
{'foo': 'bar'} | should.have.key('foo').that.should.have.length.of(3) | ||
.. code-block:: python | ||
expect('foo').to.equal.to('bar') | ||
expect('foo').to.have.length.of(3) | ||
expect({'foo': 'bar'}).to.have.key('foo').which.expect.to.be.equal('bar') | ||
expect({'foo': 'bar'}).to.have.key('foo').which.expect.to.have.length.of(3) | ||
Negation | ||
-------- | ||
|
||
not_be | ||
^^^^^^ | ||
not_present | ||
^^^^^^^^^^^ | ||
not_to | ||
^^^^^^ | ||
to_not | ||
^^^^^^ | ||
does_not | ||
^^^^^^^^ | ||
do_not | ||
^^^^^^ | ||
dont | ||
^^^^ | ||
have_not | ||
^^^^^^^^ | ||
not_have | ||
^^^^^^^^ | ||
has_not | ||
^^^^^^^ | ||
not_has | ||
^^^^^^^ | ||
that_not | ||
^^^^^^^^ | ||
which_not | ||
^^^^^^^^^ | ||
is_not | ||
^^^^^^ | ||
_not | ||
^^^^ | ||
not_satisfy | ||
^^^^^^^^^^^ | ||
|
||
Semantic chainable attributes that defines negative assertions. | ||
|
||
Typically, you will use them implicitly in order to semantically describe your assertions. | ||
|
||
======================= ======================== | ||
**Assertion mode** negation | ||
----------------------- ------------------------ | ||
**Resets context** no | ||
======================= ======================== | ||
|
||
.. code-block:: python | ||
'foo' | should.not_be.equal.to('bar') | ||
'foo' | should.have_not.length.of(3) | ||
.. code-block:: python | ||
expect('foo').to_not.equal.to('bar') | ||
expect('foo').to.not_have.length.of(3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.