Skip to main content

pyhistorian is a BDD tool for writing specifications using Given-When-Then template

Project description

The goal of pyhistorian is to write an internal Given-When-Then template using Python. The ideas came from JBehave, RBehave, Cucumber and others.

It’s possible to write your stories in English and Portuguese, choose your preferred.

A good example of use [en-us, by default] follows (call this file calculator.py):

from should_dsl import *
from pyhistorian import *

class Calculator(object):
    def sum(self, n1, n2):
        return n1+n2


class SpecifyingMyNewCalculator(Story):
    """As a lazy mathematician
       I want to use a calculator
       So that I don't waste my time thinking"""
    colored = True
    template_color = 'yellow'
    scenarios = ['SumScenario'] # optional


class SumScenario(Scenario):
    @Given('I have a calculator')
    def set_my_calculator(self):
        self.calculator = Calculator()

    @When('I enter with 1 + 1')
    def sum_one_to_one(self):
        self.result = self.calculator.sum(1, 1)

    @Then('I have $value as result', 2)
    def get_result(self, value):
        self.result |should_be| value


if __name__ == '__main__':
    SpecifyingMyNewCalculator.run()

Running:

$ python calculator.py
Story: Specifying my new calculator
As a lazy mathematician
I want to use a calculator
So that I don't waste my time thinking

Scenario 1: Sum of 1 and 1
  Given I have a calculator   ... OK
  When I enter with 1 + 1   ... OK
  Then I have 2 as result   ... OK

Ran 1 scenarios with 0 failures, 0 errors and 0 pending steps

pyhistorian is at github.com

Due to DVCS I moved pyhistorian from Google Gode to github.com.

You can get it at here:

http://github.com/hugobr/pyhistorian

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

pyhistorian-0.6.8.tar.gz (19.8 kB view details)

Uploaded Source

File details

Details for the file pyhistorian-0.6.8.tar.gz.

File metadata

  • Download URL: pyhistorian-0.6.8.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyhistorian-0.6.8.tar.gz
Algorithm Hash digest
SHA256 124fe8652dfca8c35c7027acc281148624619c11131238bf43bb3bd4b7e2a82e
MD5 47e559397e9bbf23048986bde7928eda
BLAKE2b-256 46d262683446775adf76cd593495302343080e68b563d140131a65c53ce784af

See more details on using hashes here.

Supported by

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