Skip to main content

Pytest Plugin for BDD

Project description

Eucalyptus - BDD plugin for Pytest

A nice fork of Aloe. Migrated from Nose to Pytest.

pypi pypi-versions builds docs coverage

pytest-eucalyptus has been built to feature the best of both worlds:

  • Aloe which implements great infrastructure and uses the original Gherkin parser.
  • pytest-bdd does not require a separate runner and benefits from the power and flexibility of Pytest.

Quick Start

  1. Create new module and add empty __init__.py.

  2. Install Pytest and Eucalyptus:

    pip install pytest pytest-eucalyptus
    
  3. Let's assume we are testing the following implementation of calculator.py:

        def add(*numbers):
            return sum(numbers)
    
  4. Write your first feature tests/calculator.feature:

        Feature: Add up numbers
    
        As a mathematically challenged user
        I want to add numbers
        So that I know the total
    
        Scenario: Add two numbers
            Given I have entered 50 into the calculator
            And I have entered 30 into the calculator
            When I press add
            Then the result should be 80 on the screen
    
  5. Add the definitions in tests/conftest.py:

        from calculator import add
        from pytest_eucalyptus import before, step, world
    
    
        @before.each_example
        def clear(*args):
            """Reset the calculator state before each scenario."""
            world.numbers = []
            world.result = 0
    
    
        @step(r'I have entered (\d+) into the calculator')
        def enter_number(self, number):
            world.numbers.append(float(number))
    
    
        @step(r'I press add')
        def press_add(self):
            world.result = add(*world.numbers)
    
    
        @step(r'The result should be (\d+) on the screen')
        def assert_result(self, result):
            assert world.result == float(result)
    
  6. Run the code

    $ pytest
============================= test session starts ==============================
platform darwin -- Python 3.7.3, pytest-4.6.3, py-1.8.0, pluggy-0.12.0
rootdir: /Users/eucalyptus-user/src/test
plugins: eucalyptus-0.3.0
collected 1 item                                                               

calculator.feature .                                                     [100%]

=========================== 1 passed in 0.01 seconds ===========================

Documentation

Please find more docs here.

License

Pytest-Eucalyptus is licensed under the Apache License 2.0 – see the LICENSE.md for specific details.

Project details


Download files

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

Source Distribution

pytest_eucalyptus-0.3.3.tar.gz (82.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_eucalyptus-0.3.3-py3-none-any.whl (89.7 kB view details)

Uploaded Python 3

File details

Details for the file pytest_eucalyptus-0.3.3.tar.gz.

File metadata

  • Download URL: pytest_eucalyptus-0.3.3.tar.gz
  • Upload date:
  • Size: 82.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.1

File hashes

Hashes for pytest_eucalyptus-0.3.3.tar.gz
Algorithm Hash digest
SHA256 18e9762207f3cffc8114141705eb07798121bfe29d3985c390c091a136c33484
MD5 f1e36a4584fd8b21b45e0acacbd59ef7
BLAKE2b-256 54579c2ab85a954f3c9bd3d54c48f86fdc26b10b116cb634cc19a18f01cecf85

See more details on using hashes here.

File details

Details for the file pytest_eucalyptus-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: pytest_eucalyptus-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 89.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.1

File hashes

Hashes for pytest_eucalyptus-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6ad3776fba884a7a17ba54fa61a05ddd590af936cb883a08b4a48261985efa90
MD5 f97876d00048ccdbf2501353b54c4b5b
BLAKE2b-256 f56daaa1ea4da6536b41dc68908b27b871731c8058c2a33d7a246a90762b173a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page