pyhistorian是一个bdd工具,用于使用给定的when-then模板编写规范

pyhistorian的Python项目详细描述


pyhistorian的目标是使用python编写给定的内部模板。 这些想法来自于jbehave、rbehave、cucumber和其他人。

你可以用英语和葡萄牙语写故事,选择你喜欢的。

下面是一个使用[en-us, by default]的好例子(调用这个文件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()

跑步:

$ 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位于github.com

由于dvcs,我将pyhistorian从Google Gode移到了github.com

你可以在here

http://github.com/hugobr/pyhistorian

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java应该考虑使用DTO来代替Spring控制器层吗?   java为什么要将Maven与Git结合起来?   java试图将CSV转换为XLSX,但使用了错误的逗号拆分列   mysql Spring 3+Hibernate:java。sql。BatchUpdateException:无法添加或更新子行(ManyToMany)   java基本字符串反转器   java无法使用RestControllerAdvice为身份验证失败生成自定义错误消息   java当只允许SQLException时,如何抛出EOFEException?   java如何创建播放模块?   Android中匿名类的java实例化异常问题   java两个停靠组件,其中第二个组件填充剩余空间   java如何在按钮延迟时启用它   Java中正在运行的应用程序中的后台进程   java我正试图从一个字符串打印出这个字符输出   如何使用java socket通过两个不同的wifi连接两台电脑?   javaapachecamel:如何将分层数据从数据库转换为pojo   java Webrtc:OniconConnectionChange和onConnectionChange之间有什么区别   java如何重写已经创建的JTable方法   爪哇扫雷机堆垛机   雅加达ee Java ee EJB 3.0 Glassfish