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双端队列(Deque)快速排序   java隐藏成功测试的日志   如何在java中循环某些内容?   java从ArrayList中删除重复对象   java在使用关键字驱动从Excel文件中获取数据时遇到了执行测试用例的问题   javasql生成表   java mavenshadeplugin不包括uber jar中其他模块的依赖项   Java泛型类找不到方法   使用Android和iOS的java通知   php如何在Java中解密aes256cbc   类当我已经导入枚举类所在的包时,为什么需要导入枚举类才能使用它们?[爪哇]   java未经检查的强制转换有什么问题?   io如何在使用java zip压缩压缩文件时将文件拆分为多个文件?   在java中,字典随机访问给定密钥的映射条目   Java登录表单