Code Monkey home page Code Monkey logo

mamba's Introduction

#mamba: the definitive testing tool for Python

Build Status

mamba is the definitive BDD testing framework for Python. Born under the banner of Behavior Driven Development.

##Installation

To install mamba, just:

pip install mamba

##Overview

# Importing mamba is not needed!
# import mamba

with description('mamba'):
    with it('is tested with mamba itself'):
        pass

    with it('supports python 3'):
        pass

    with context('when listing features'):
        with it('supports example groups'):
            pass

        with context('hooks'):
            with before.all:
                print 'This code will be run once, before all examples'

            with before.each:
                print 'This code will be run before each example'

            with after.each:
                print 'This code will be run after each example'

            with after.all:
                print 'This code will be run once, after all examples'

        with context('pending tests'):
            with _context('when running pending contexts (marked with a underscore)'):
                with it('will not run any spec under a pending context'):
                    pass

            with _it('will not run pending specs (marked with underscore)'):
                pass

        with it('highlights slow tests'):
            sleep(10)

        with context(ASampleClass):
            with it('has an instance in subject property'):
                expect(self.subject).to.be.a(ASampleClass)

    with context('when writing assertions'):
        with it('can be used with plain assertions'):
            assert True

        with it('can be used with hamcrest style assertions'):
            assert_that(True, is_(True))

        with it('can be used with should_dsl style assertions'):
            True |should| be(True)

        with it('can be used with sure style assertions'):
            True.should.be.true

            expect(True).to.be.true

        with it('is assertion framework agnostic'):
            pass

    with context('when using tests doubles'):
        with it('can be used with mockito'):
            stub = mock()
            when(stub).is_usable_with_mockito().thenReturn(True)

            expect(stub.is_usable_with_mockito()).to.be.true

        with it('can be used with doublex'):
            with Spy() as sender:
                sender.is_usable_with_doublex().returns(True)

            assert_that(sender.is_usable_with_doublex(), is_(True))
            assert_that(sender.is_usable_with_doublex, called())

        with it('can be used with mock'):
            is_usable_with_mock = Mock(return_value=True)

            assert mock()

        with it('is test doubles framework agnostic'):
            pass

    with context('when code coverage measurement is desired'):
        with it('collects them if you pass `--enable-coverage`'):
            pass

        with it('calls `coverage` directly in order to compute it'):
            # see https://pypi.python.org/pypi/coverage/
            pass

        with it('is configured in a `.coveragerc` file at the root of your project'):
            # see http://nedbatchelder.com/code/coverage/config.html
            pass

##Contribute

If you'd like to contribute, fork repository, and send a pull request.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.