如何处理生菜中的多语言数据?

How to handle multilingual data in lettuce?

我写了一个 *.feature 文件和 step.py with lettuce 可以正常工作,但是当我将波斯语数据放入 *.feature 文件时,它停止工作。

这是我的功能文件:

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

我该怎么做?

如果您想使用 string,您需要 引号。功能文件应如下所示。

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

并在步骤文件中:

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

希望对您有所帮助。使用字符串的步骤定义在 documentation

的主页上

感谢您的回答。 我使用

解决了这个问题

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

这项工作很好,可以接受空格。