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 Ajax请求:Spring mvc maven项目   java修改对象会更改Ehcache值   java MBTiles文件有大小限制吗?   java服务:amazons3;状态代码:404;错误代码:NoSuchBucket;从IBM云对象存储获取文件时遇到问题   启动Java项目IDE、框架等的模型视图控制器。   java ActiveMQ,代理接收要发送的消息的时间戳   Java数组:方法不起作用   关于二进制搜索树的java问题将值插入到二进制搜索树   LWJGL在使用“java<class file>”命令时找不到类错误   java JVM崩溃,出现异常访问违反ntdll。dll+0x1b96f   java SSL握手挂起   当脚本显示在HTML文本区域中时,java是否可能进行XSS攻击?   java使用JSP创建购物车并将数据插入数据库   java如何使customActionBar透明并更改其文本颜色?