user3111884 February 2016

Behave / python3: Test undefined even if the step function is present

I have started using behave to define behaviour-driven tests on Python3. The first tests went fine, but now I am incurring in a most puzzling error.

I have define this Gherkin file sra-to-isatab-batch-conversion.feature:

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

Then I define the following step methods in a file steps/sra-to-isatab-batch-conversion.py

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

If I then run behave sra-to-isatab-conversion.feature the step function related to the when step appears to be missing:

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                                                                    

Answers


Carlos Melo February 2016

hmmm, its currently working just fine for me with your exact implementation as you pasted above. Could be an environment issue or and installation problem. Can you try reinstalling behave? also are you running it from your terminal or from pycharm?

PS: not an issue, but you don't need to specify the use_step_matcher() method if you are using parse; since its the default step_matcher

Also (making sure not a pasting human error from you): your @when step method has an indentation issue on the "pass" statement. Is it really like that in your code or just a format issue here in the forum?

Post Status

Asked in February 2016
Viewed 3,496 times
Voted 10
Answered 1 times

Search




Leave an answer