Readability Matters
Project description
Baby Steps
BDD steps for test markup. Just for readability.
Installation
pip3 install baby-steps
Usage
import httpx
from baby_steps import given, when, then
def test_status_code():
with given:
code = 200
with when:
resp = httpx.get(f"https://httpbin.org/status/{code}")
with then:
assert resp.status_code == code
Named Steps
import httpx
from baby_steps import given, when, then
def test_status_code():
with given("status code"):
code = 200
with when("user requests a resource"):
resp = httpx.get(f"https://httpbin.org/status/{code}")
with then("it should return expected status code"):
assert resp.status_code == code
Hooks
from baby_steps import given, then, when
from baby_steps.hooks import add_hook
def test():
with given("status code"):
pass
with when("user requests a resource"):
pass
with then("it should return expected status code"):
pass
def hook(step, name):
print(step, name)
add_hook(hook)
test()
# <class 'baby_steps.Given'> 'status code'
# <class 'baby_steps.When'> 'user requests a resource'
# <class 'baby_steps.Then'> 'it should return expected status code'
Advanced
from baby_steps import when
from baby_steps.hooks import add_hook
def test():
with when:
print("when")
def hook(step, name):
print("before", step)
yield
print("after", step)
add_hook(hook)
test()
# before <class 'baby_steps.When'>
# when
# after <class 'baby_steps.When'>
Custom Steps
from baby_steps import Step
class AndThen(Step):
pass
and_then = AndThen()
with and_then("smth"):
pass
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
baby-steps-1.2.3.tar.gz
(7.0 kB
view hashes)
Built Distribution
Close
Hashes for baby_steps-1.2.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b024d5d2de1bf9d5b22ef84864ac80ebf80e117409a227ca6ff0ed29de2a0c95 |
|
MD5 | 4376c84b6dbfd77bde252901e690a119 |
|
BLAKE2b-256 | ff764bb534733a7a2c4ed5af8378a706df0795514c2f7ece69de9a34595ec85e |