Skip to main content

mamba: the definitive test runner for Python

Build Status Latest PyPI Version Read The Docs Status PyPI pyversions

mamba is the definitive test runner for Python. Born under the banner of behavior-driven development.

Install

I recommend to use pipenv for managing your dependencies, thus you can install mamba like any other Python package.

By example:

  $ pipenv install mamba

But you also can use pip:

  $ pip install mamba

Getting Started

Write a very simple example that describes your code behaviour:

  # tennis_spec.py

  from mamba import description, context, it
  from expects import expect, equal

  with description('Tennis') as self:
    with it('starts with 0 - 0 score'):
      rafa_nadal = "Rafa Nadal"
      roger_federer = "Roger Federer"
      game = Game(rafa_nadal, roger_federer)

      expect(game.score()).to(equal((0, 0)))

Run the example, and don't forget to watch it fail!

  $ pipenv run mamba tennis_spec.py

  F

  1 examples failed of 1 ran in 0.0023 seconds

  Failures:

    1) Tennis it starts with 0 - 0 score
      Failure/Error: tennis_spec.py game = Game(rafa_nadal, roger_federer)
          NameError: global name 'Game' is not defined

      File "tennis_spec.py", line 8, in 00000001__it starts with 0 - 0 score--
          game = Game(rafa_nadal, roger_federer)

Now write as little code for making it pass.

  # tennis_spec.py

  from mamba import description, context, it
  from expects import expect, equal

  import tennis

  with description('Tennis') as self:
    with it('starts with 0 - 0 score'):
      rafa_nadal = "Rafa Nadal"
      roger_federer = "Roger Federer"
      game = tennis.Game(rafa_nadal, roger_federer)

      expect(game.score()).to(equal((0, 0)))
  # tennis.py

  class Game(object):
    def __init__(self, player1, player2):
      pass

    def score(self):
      return (0, 0)

Run the spec file and enjoy that all tests are green!

  $ pipenv run mamba tennis_spec.py

  .

  1 examples ran in 0.0022 seconds

Settings

Mamba provides a way to configuration using spec/spec_helper.py or specs/spec_helper.py This module function is read after parsing arguments so configure function overrides settings

A sample config file :

def configure(settings):
  # settings.slow_test_threshold = 0.075
  # settings.enable_code_coverage = False
  # settings.code_coverage_file = '.coverage'
  settings.format = 'documentation'
  # settings.no_color = False
  # settings.tags = None

Official Manual

You can read more features about mamba in its official manual

Contributors

Here's a list of all the people who have contributed.

I'm really grateful to each and every of them!

If you want to be one of them, fork repository and send a pull request.

Release files for mamba 0.11.1

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

Source distribution (sdist)

Source distribution for mamba 0.11.1
File Size Uploaded
mamba-0.11.1.tar.gz 13.5 kB Details

Release files / mamba-0.11.1.tar.gz

Download URL mamba-0.11.1.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f976735949bc9a8731cc0876aaea2720949bd3d1554b0e94004c91a4f61abecb
BLAKE2b-256 checksum
How to use checksums
56c9a4f65a0ed427b4ac60a85b0e7980b9caad321f448594db7b4954904b40ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.5

Release history Release notifications | RSS feed

0.11.3

1 release file

0.11.2

1 release file

This release

0.11.1 This release

1 release file

0.11.0

1 release file

0.10

1 release file

0.9.3

1 release file

0.9.2

1 release file

0.9.1

1 release file

0.8.6

1 release file

0.8.5

1 release file

0.8.4

1 release file

0.8.3

1 release file

0.8.2

1 release file

0.8.1

1 release file

0.8

1 release file

0.6

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

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