Eucalyptus - BDD plugin for Pytest
A nice fork of Aloe. Migrated from Nose to Pytest.
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
-
Create new module and add empty
__init__.py. -
Install Pytest and Eucalyptus:
pip install pytest pytest-eucalyptus
-
Let's assume we are testing the following implementation of
calculator.py:def add(*numbers): return sum(numbers)
-
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 -
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)
-
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.
Release files for pytest-eucalyptus 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest_eucalyptus-0.4.1.tar.gz | 88.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_eucalyptus-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 171.4 kB
Release files / pytest_eucalyptus-0.4.1.tar.gz
| Download URL | pytest_eucalyptus-0.4.1.tar.gz |
|---|---|
| Size | 88.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
90482628b64943b29c544413d7bacace39f9557a219cf69a0be0d77b102a80e4
|
|
BLAKE2b-256 checksum How to use checksums |
76f934d277a418ccfc17f5ebc88c4c31aae41b8066d41ceead7b0e9d49b21572
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / pytest_eucalyptus-0.4.1-py3-none-any.whl
| Download URL | pytest_eucalyptus-0.4.1-py3-none-any.whl |
|---|---|
| Size | 82.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7d5996ad937e859b3d4ae452266cbd3eac1078de559fe445d2106180d4e91251
|
|
BLAKE2b-256 checksum How to use checksums |
ee2c4f5ef07103cc70873c697f5aa3237eac5e4f51cafb9e1dd11637cf592de0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|