skip to navigation
skip to content

Not Logged In

describe_it 2.1.0

A nose plugin that supports writing describe/it style unit tests with nested contexts


$ pip install describe-it


Any module that ends with ‘spec’ is considered to contain specifications/tests for describe_it.

$ vim

…and the content:

from game import Game
from describe_it import describe, it, before_each, Fixture

@describe           # This declares a test context.
def a_game():
    f = Fixture()   # Fixture is a hack to get around Python's
                    # implementation of closures. You can use
                    # other methods, such as nonlocal if you like.

    @before_each    # Will be called before each 'it' method.
    def setup(): = Game()

    @after_each     # Will be called after each 'it' method.
    def teardown():
        # This should rarely be needed!

    @it             # This marks a test method.
    def is_player_ones_turn():
        # describe_it doesn't come with yet another assertion lib.
        # Pick any one you like.
        assert == 1

    @describe   # This is a nested context that augments the context above.
    def in_second_round():

        # Before each 'it' method, any before_each in outer
        # contexts will be called first. Then this method
        # will be called.
        def setup():

        def is_player_twos_turn():
            assert == 2

 # You can skip whole contexts by using '@xdescribe' or '@describe_skip'
 def this_context_is_marked_as_skipped():

    def this_test_will_be_skipped():
        assert True

 def context_with_a_skipped_it_method():

    # You can skip individual test methods by using '@xit' or '@it_skip'
    def this_test_will_be_skipped():
        assert True

    def this_test_will_be_run():
        assert True


$ nosetests --with-describe-it
File Type Py Version Uploaded on Size (md5) Source 2015-05-08 9KB
  • Downloads (All Versions):
  • 19 downloads in the last day
  • 282 downloads in the last week
  • 924 downloads in the last month