Metadata-Version: 1.1
Name: robber
Version: 1.0.0
Summary: BDD / TDD assertion library for Python
Home-page: https://github.com/vesln/robber.py
Author: Tao Liang
Author-email: tao@synapse-ai.com
License: UNKNOWN
Description: |Build Status| |Coverage Status|
        
        robber.py - BDD / TDD assertion library for Python.
        ===================================================
        
        Synopsis
        --------
        
        In order to use ``robber``, you need to import ``expect`` from the
        module:
        
        .. code:: python
        
            from robber import expect
        
        That's all. You are good to go.
        
        Assertions
        ~~~~~~~~~~
        
        eq/==
        ^^^^^
        
        Asserts that actual is equal (==) to expected:
        
        .. code:: python
        
            expect(1).to.eq(1)
            expect([1, 2]).to.eq([1, 2])
        
        Also:
        
        .. code:: python
        
            expect(1) == 1
        
        ne/not\_eq/!=
        ^^^^^^^^^^^^^
        
        Asserts that actual is not equal (!=) to expected:
        
        .. code:: python
        
            expect(1).to.ne(2)
            expect(1).to.not_eq(2)
            expect(1).to != 2
            expect(1) != 2
        
        equal
        ^^^^^
        
        Asserts that the target is identical (is) to the expected:
        
        .. code:: python
        
            expect(1).to.equal(1)
        
        not\_equal
        ^^^^^^^^^^
        
        Asserts that the target is not identical (is) to the expected:
        
        .. code:: python
        
            expect({ 'test': 'robber' }).to.not_equal({ 'test': 'robber' })
        
        true
        ^^^^
        
        Asserts that the target is True:
        
        .. code:: python
        
            expect(True).to.be.true()
        
        false
        ^^^^^
        
        Asserts that the target is False:
        
        .. code:: python
        
            expect(False).to.be.false()
        
        instanceof
        ^^^^^^^^^^
        
        Asserts that the target is an instance of expected:
        
        .. code:: python
        
            expect(obj).to.be.instanceof(Klass)
        
        match
        ^^^^^
        
        Asserts that the target can be matched by a regular expression:
        
        .. code:: python
        
            expect('foo').to.match(r'foo')
        
        not\_match
        ^^^^^^^^^^
        
        Asserts that the target can not be matched by a regular expression:
        
        .. code:: python
        
            expect('bar').to.not_match(r'foo')
        
        respond\_to
        ^^^^^^^^^^^
        
        Asserts that the target responds to a method:
        
        .. code:: python
        
            expect(obj).to.respond_to('method')
        
        truthy
        ^^^^^^
        
        Asserts that the target is truthy:
        
        .. code:: python
        
            expect(['test']).to.be.truthy()
        
        falsy
        ^^^^^
        
        Asserts that the target is falsy:
        
        .. code:: python
        
            expect([]).to.be.falsy()
        
        length
        ^^^^^^
        
        Asserts that the target has a length of expected:
        
        .. code:: python
        
            expect([1, 2]).to.have.length(2)
            expect('str').to.have.length(3)
        
        empty
        ^^^^^
        
        Asserts that the target is empty:
        
        .. code:: python
        
            expect([]).to.be.empty()
            expect('').to.be.empty()
        
        not\_empty
        ^^^^^^^^^^
        
        Asserts that the target is nonempty:
        
        .. code:: python
        
            expect([1, 2, 3]).to.be.not_empty()
            expect('foo').to.be.not_empty()
        
        string
        ^^^^^^
        
        Asserts that the target is a string:
        
        .. code:: python
        
            expect('str').to.be.a.string()
        
        integer
        ^^^^^^^
        
        Asserts that the target is an integer:
        
        .. code:: python
        
            expect('str').to.be.an.integer()
        
        float
        ^^^^^
        
        Asserts that the target is floating point number:
        
        .. code:: python
        
            expect(1.0).to.be.a.float()
        
        list
        ^^^^
        
        Asserts that the target is a list:
        
        .. code:: python
        
            expect([1, 2]).to.be.a.list()
        
        dict
        ^^^^
        
        Asserts that the target is a dictionary:
        
        .. code:: python
        
            expect({}).to.be.a.dict()
        
        tuple
        ^^^^^
        
        Asserts that the target is a tuple:
        
        .. code:: python
        
            expect((1, 2)).to.be.a.tuple()
        
        none
        ^^^^
        
        Asserts that the target is None:
        
        .. code:: python
        
            expect(None).to.be.none()
        
        above
        ^^^^^
        
        Asserts that the target is above expected:
        
        .. code:: python
        
            expect(2).to.be.above(1)
        
        below
        ^^^^^
        
        Asserts that the target is below expected:
        
        .. code:: python
        
            expect(1).to.be.below(2)
        
        within
        ^^^^^^
        
        Asserts that the target is within expected:
        
        .. code:: python
        
            expect(2).to.be.within(0, 2)
        
        contain
        ^^^^^^^
        
        Asserts that the target contains an element, or a key:
        
        .. code:: python
        
            expect([1,2,3]).to.contain(2)
            expect({'foo': 'bar'}).to.contain('foo')
        
        not\_contain/exclude
        ^^^^^^^^^^^^^^^^^^^^
        
        Asserts that the target does not contain an element, or a key:
        
        .. code:: python
        
            expect([1,2,3]).to.not_contain(4)
            expect({'foo': 'bar'}).to.exclude('baz')
        
        Language chains
        ~~~~~~~~~~~~~~~
        
        In order to write more readable assertions, there are a few built-in
        language chains that you can use:
        
        -  to
        -  be
        -  a
        -  an
        -  have
        
        For example, the following two lines are functionally equivalent:
        
        ::
        
            expect(1.0).to.be.a.float()
        
            expect(1.0).float()
        
        Expectation chaining
        ~~~~~~~~~~~~~~~~~~~~
        
        In the spirit of more readable assertions, and to eliminate redundant
        evaluations of the same expression, you can chain multiple expectations.
        
        For example, the following two lines are functionally equivalent. The
        first example evaluates the expression '1 + 1' only once:
        
        ::
        
            expect(1 + 1).to.be.an.integer().to.be.within(1, 3)
        
            expect(1 + 1).to.be.an.integer()
            expect(1 + 1).to.be within(1, 3)
        
        Custom assertions
        ~~~~~~~~~~~~~~~~~
        
        Writing custom assertion is as easy as extending a base matcher class
        and adding two methods - matches for matching and failure\_message for
        the error notice:
        
        .. code:: python
        
            class Chain(Base):
                def matches(self):
                    expectation = self.actual(None)
                    chain = getattr(expectation, self.expected)
                    return expectation is chain
        
                def failure_message(self):
                    return 'Expected "%s" to have chain "%s"' % (self.actual, self.expected)
        
            expect.register('chain', Chain)
        
        After you register the new matcher, you can use it as expected:
        
        .. code:: python
        
            expect(obj).to.have.chain('be')
        
        Custom error messages
        ~~~~~~~~~~~~~~~~~~~~~
        
        If you want to have custom failure messages, for assertion or group of
        assertions, you can simply do:
        
        .. code:: python
        
            from robber import failure_message
        
            with failure_message('Something went wrong'):
                expect(1).to.eq(2)
        
        Installation
        ------------
        
        ::
        
            $ pip install robber
        
        Requirements
        ------------
        
        -  Python 2.6, 2.7 or 3.5
        -  pip
        -  nose (for testing)
        
        Tests
        -----
        
        ::
        
            $ nosetests tests/
        
        License
        -------
        
        MIT License
        
        .. |Build Status| image:: https://secure.travis-ci.org/taoenator/robber.py.png
           :target: http://travis-ci.org/taoenator/robber.py
        .. |Coverage Status| image:: https://coveralls.io/repos/github/taoenator/robber.py/badge.svg?branch=master
           :target: https://coveralls.io/github/taoenator/robber.py?branch=master
        
Platform: UNKNOWN
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Testing
