首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Behave / python3:测试未定义,即使存在阶跃函数

Behave / python3:测试未定义,即使存在阶跃函数
EN

Stack Overflow用户
提问于 2016-02-09 02:00:05
回答 1查看 3.1K关注 0票数 1

我已经开始使用behaviour在Python3上定义行为驱动的测试。第一次测试进行得很顺利,但现在我遇到了一个最令人费解的错误。

我已经定义了这个小黄瓜文件sra-to-isatab-batch-conversion.feature

代码语言:javascript
复制
Feature: SRA to ISA-tab Batch conversion
# perform a batch conversion of a set of SRA datasets, retrieved from the European Nucleotide Archive
# to ISA-tab

Scenario: Batch conversion form a list of SRA accession numbers
 Given An access number "ERA000084"
 And nothing else
 When the SRA to ISA tab conversion is invoked
 Then it should return a ZIP file object
 And the ZIP file should contain as many directories as the element in the list

然后,我在文件steps/sra-to-isatab-batch-conversion.py中定义了以下步骤方法

代码语言:javascript
复制
from behave import *

use_step_matcher("parse")


@given('An access number "{access_number}"')
def step_impl(context, access_number):
    context.access_number = access_number
    print(context.access_number)

@step("nothing else")
def step_impl(context):
    print("Nothing else") 


@when("the SRA to ISA tab conversion is invoked")
def step_impl(context):
 pass


@then("it should return a ZIP file object")
def step_impl(context):
    pass


@step("the ZIP file should contain as many directories as the element in the list")
def step_impl(context):
    pass

如果我随后运行behave sra-to-isatab-conversion.feature,则与when步骤相关的步骤函数似乎丢失:

代码语言:javascript
复制
Feature: SRA to ISA-tab Batch conversion # sra-to-isatab-batch-conversion.feature:2

Scenario: Batch conversion form a list of SRA accession numbers                  # sra-to-isatab-batch-conversion.feature:6
Given An access number "ERA000084"                                             # steps/sra-to-isatab-batch-conversion.py:6 0.000s
And nothing else                                                               # steps/sra-to-isatab-batch-conversion.py:40 0.000s
When the SRA to ISA tab conversion is invoked                                  # None
Then it should return a ZIP file object                                        # None
And the ZIP file should contain as many directories as the element in the list # None

/Users/massi/Projects/oerc/isa-api/features/test_outputs

Failing scenarios:
  sra-to-isatab-batch-conversion.feature:6  Batch conversion form a list of SRA accession numbers

0 features passed, 1 failed, 0 skipped
0 scenarios passed, 1 failed, 0 skipped
2 steps passed, 0 failed, 2 skipped, 1 undefined
Took 0m0.001s

You can implement step definitions for undefined steps with these snippets:

@when(u'the SRA to ISA tab conversion is invoked')
def step_impl(context):
    raise NotImplementedError(u'STEP: When the SRA to ISA tab conversion is invoked')`

我尝试重新定义步骤描述更改给定语句的数量,我甚至重写了文件,但我总是得到相同的错误。即使我复制了错误消息中建议的语句,我仍然得到完全相同的错误。

谁能给我解释一下我做错了什么?我使用的是Python3.4behavior 1.2.5 PyCharm 5.0.4 (请注意,PyCharm BDD工具可以识别小黄瓜文件中语句和步骤函数之间的匹配)

EN

回答 1

Stack Overflow用户

发布于 2016-02-10 04:27:37

嗯,就像你在上面粘贴的那样,它目前对我来说工作得很好。可能是环境问题或安装问题。你能尝试重新安装behave吗?另外,你是在你的终端上还是在pycharm上运行它?

PS:没问题,但是如果您使用的是parse,就不需要指定use_step_matcher()方法;因为它是默认的step_matcher

另外(确保不是你的粘贴人为错误):你的@when步骤方法在"pass“语句上有一个缩进问题。在你的代码中真的是这样吗?或者只是论坛里的一个格式问题?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35276199

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档