Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Behaviour Driven Development in Python

Project Description

Behaviour provides a language suitable for Behaviour Driven Development (BDD), as opposed to post-coding unit testing. It operates as a facade over Python’s unit testing framework.

What is Behaviour Driven Development?

BDD is a derivative of Test Driven Development (TDD), evolving out of the observed adoption-life-cycle for TDD:

  1. A developer starts using a unit testing framework (like
  2. The developer becomes more confident in the quality of his work.
  3. They realize that writing the tests first lets them concentrate on writing the code they needs.
  4. The developer notices that the tests document the code.
  5. Writing tests first helps the developer to design the API for their code.
  6. The developer realizes that TDD is about defining behaviour rather than testing.
  7. The developer adopts mocking as a fundamental approach to support component interactions.

BDD supports the progression through that life-cycle, particularly the last three steps.

BDD supports this transition is by providing an appropriate language. Frameworks for BDD talk about either specifications (e.g., RSpec for Ruby, NSpec for C#.NET) or behaviours (e.g., JBehave for Java, NBehave for .NET).

For more information on BDD, see:

What does Behaviour do for Me?

Behaviour allows you to say things like:

class verifyUserSpecification( behaviour.Behaviour ):

        def setUp( self ):

                self.user = User( "Mark Dancer" )

        def verifyInitialUserNameIsNameInConstructor( self ):

                self.shouldBeEqual(, "Mark Dancer" )

        def verifyInitialUserHasNoLanguages( self ):

                self.shouldBeEmpty( self.user.languages )

This has no more expressive power than what is offered by unittest:

class testUser( unittest.TestCase ):

        def setUp( self ):

                self.user = User( "Mark Dancer ")

        def testName( self ):

                self.failUnlessEqual(, "Mark Dancer" )

        def testLanguages( self ):

                self.failUnless( self.user.languages = [] )

What it does offer is an alternative set of semantics.

With the semantics of unittest, we are testing a piece of code that we have already written.

With Behaviour, we are writing a specification for the piece of code we are about to write. It is much clearer with BDD that the specification is written before the code.

Release History

Release History

This version
History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
Behaviour-0.1a4-py2.5.egg (46.0 kB) Copy SHA256 Checksum SHA256 2.5 Egg Dec 22, 2007
Behaviour-0.1a4.tar.gz (29.4 kB) Copy SHA256 Checksum SHA256 Source Dec 22, 2007 (50.2 kB) Copy SHA256 Checksum SHA256 Source Dec 22, 2007

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting