0

I have started to refactor a project at the company I work with. The structure looks like this:

root
 |---features
 |      |-masks.feature
 |
 |---steps_def
 |      |-test_article.py
 |      |-test_author.py
 |      |-conftest.py

I am fairly new to pytest-bdd, I'm following their latest doc: https://pytest-bdd.readthedocs.io/en/stable/index.html

I have 1 feature in masks.feature and 1 scenario there. My scenario is using steps from both test_author.py & test_article.py.

Question #1:

Looking at the scenarios shortcut section, I have added scenarios('../features') to test_article.py file. When I do that, running pytest seems to collect the same test twice. When I remove it from test_article.py and add it to test_author.py it runs as expected (only once) - why? what is the logic behind that?

Question #2: test_article.py is creating a fixture via target_fixture in a step that is being used under test_author.py. My only way for pytest to recgonise this fixture is by doing from steps_def.test_editor import *, why I need to import whole file for that fixture?

Saidden
  • 111
  • 4

0 Answers0