pytest-dev / pytest-bdd

BDD library for the pytest runner
https://pytest-bdd.readthedocs.io/en/latest/
MIT License
1.31k stars 220 forks source link

@pytest.mark.scenario Does not appear to exist #169

Closed jtpereyda closed 8 years ago

jtpereyda commented 8 years ago

tl;dr

README references @mark.scenario decorator from pytest.mark, but it appears that plain old @scenario from pytest is the way to go.

Problem

According to the readme, you can parameterize tests like this (selected excerpts from example):

import pytest
from pytest_bdd import mark, given, when, then

...
@pytest.mark.parametrize(
    ['start', 'eat', 'left'],
    [(12, 5, 7)])
@mark.scenario(
    'parametrized.feature',
    'Parametrized given, when, thens',
)
...
def test_parametrized(start, eat, left):
...

However, these import lines fail for me with the latest pytest-bdd:

$ cat test_import_fail.py
import pytest
import pytest_bdd
print("pytest: {0}", pytest.__version__)
print("pytest_bdd: {0}", pytest_bdd.__version__)
from pytest_bdd import mark, given, when, then

$ ./env/bin/python test_import_fail.py
pytest: 2.8.5
pytest_bdd: 2.16.0
Traceback (most recent call last):
  File "test_import_fail.py", line 5, in <module>
    from pytest_bdd import mark, given, when, then
ImportError: cannot import name mark

Solution

However, everything works fine for me if I change

from pytest_bdd import mark, given, when, then

to

from pytest_bdd import scenario, given, when, then

and

@mark.scenario(

to

@scenario(

Suggestion

Change README.

Also "parameterization" is misspelled "parametrization" in the README. Apparently there are four ways to spell parametrise.

spinus commented 8 years ago

Good catch

jtpereyda commented 8 years ago

Closing since PR was merged