Skip to main content

describe it

buildstatus

Describe-it is a nose plugin that allows you to write unit tests that are more like executable examples of how a component should work than just being tests.

The other benefit is the ability to describe how a component behaves in certain contexts, where one context may build on a previously defined context by using nesting.

Installing

$ pip install describe-it

Writing

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

$ vim myfirst_spec.py

…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'
    def setup():
        f.game = Game()

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

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

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

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

        @it
        def is_player_twos_turn():
            assert f.game.current_player == 2

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

        @with_data([1, 2, 3],                           # You can parameterize tests with
                   [3, 4, 7])                           # different combinations of inputs
        def adds_numbers(term_1, term_2, expected):
            assert term_1 + term_2 == expected

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

    @it
    def this_test_will_be_skipped():
        assert True

Running

$ nosetests --with-describe-it

Metadata

Release files for describe_it 2.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for describe_it 2.2.2
File Size Uploaded Provenance Actions
describe_it-2.2.2.tar.gz 5.1 kB Without provenance Details for describe_it-2.2.2.tar.gz

Release files / describe_it-2.2.2.tar.gz

Download URL describe_it-2.2.2.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
538b684ad6e6920da35b57ae4f52cdc35e94ba7941e6b4b7d65e38972f75d336
BLAKE2b-256 checksum
How to use checksums
75ca175bfd9a0de65af77cf7c197c59ea13c97bdb6c1dfb87dd856153b100dcd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for describe_it 2.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page