代码之家  ›  专栏  ›  技术社区  ›  ahmadsl

如何处理莴苣中的多语言数据?

  •  2
  • ahmadsl  · 技术社区  · 9 年前

    这是我的功能文件:

    Feature: Computefactorial
    In order to play with Lettuce
    As beginners
    We'll implement factorial
    
    Scenario: Factorial of 0
        Given I have the number 0
        When I compute its factorial
        Then I see the number علی
    

    这是我的step.py:

    from lettuce import *
    
    @step('I have the number (\d+)')
    def have_the_number(step, number):
        world.number = int(number)
    
    @step('I compute its factorial')
    def compute_its_factorial(step):
        world.number = factorial(world.number)
    
    @step('I see the number (\w+)')
    def check_number(step, expected):
        #expected = int(expected)
        assert True
    
    def factorial(number):
        return -1
    

    2 回复  |  直到 9 年前
        1
  •  0
  •   Daniel Fintinariu    9 年前

    如果你想使用 string 你需要 。功能文件应如下所示。

    Scenario: Factorial of 0
        Given I have the number 0
        When I compute its factorial
        Then I see the number "علی"
    

    在step文件中:

    ...
    @step('I see the number "(\w+)"')
    def check_number(step, expected):
        #expected = int(expected)
        assert True
    ...
    

    documentation

        2
  •  0
  •   ahmadsl    9 年前

    谢谢你的回答。

    @step('I see the number ([\s|\S]*)')

    这很好,可以接受空间。