Comments (7)
will check
On 10 September 2014 18:57, Robin Pedersen [email protected] wrote:
I have prepared a minimal case to demonstrate this issue:
https://github.com/ropez/pytest-bdd-issueHaving a conftest.py in a subdirectory, and the subdirectory also having
a init.py, the conftest module is evaluated twice. This is an
important issue, because any hooks added there, such as pytest_pyfunc_call,
will be registered twice, and called twice for each test case. This is
causing problems in our actual, much bigger, project.Removing pytest-bdd from the equation, for instance by commenting out the
@Scenario decorator to make it a simple test function, removed the
problem. Also, running py.test inside the subdirectory, or deleting the
init.py file, removes the problem.—
Reply to this email directly or view it on GitHub
#62.
Anatoly Bubenkov
from pytest-bdd.
and how do you run this example?
for me it works with np!
┌─[vagrant@paylogic-virtual] - [~/workspace/pytest-bdd-issue] - [2014-09-10
06:01:47]
└─[0] <git:(master 3f7452✈) > py.test foo -s
foo.conftest
===================================================================== test
session starts
platform linux2 -- Python 2.7.6 -- py-1.4.24 -- pytest-2.6.2
plugins: bdd, bdd
collecting 0 items
conftest
collected 1 items
foo/test_foo.py .
================================================================== 1 passed
in 0.01 seconds
On 10 September 2014 19:57, Anatoly Bubenkov [email protected] wrote:
will check
On 10 September 2014 18:57, Robin Pedersen [email protected]
wrote:I have prepared a minimal case to demonstrate this issue:
https://github.com/ropez/pytest-bdd-issueHaving a conftest.py in a subdirectory, and the subdirectory also having
a init.py, the conftest module is evaluated twice. This is an
important issue, because any hooks added there, such as
pytest_pyfunc_call, will be registered twice, and called twice for each
test case. This is causing problems in our actual, much bigger, project.Removing pytest-bdd from the equation, for instance by commenting out the
@Scenario decorator to make it a simple test function, removed the
problem. Also, running py.test inside the subdirectory, or deleting the
init.py file, removes the problem.—
Reply to this email directly or view it on GitHub
#62.Anatoly Bubenkov
Anatoly Bubenkov
from pytest-bdd.
I run it without the 'foo' argument: py.test -s
(obsiously, the example is simplified, but imagine that you also have other directories where you want to find tests, like bar/test_bar.py
)
from pytest-bdd.
now i get it :)
looks like it's because of the custom mechanism of the conftest lookup
which pytest-bdd needs to get the feature folder base
so it imports conftests from the place where scenario is, and the module
name is different if you import it from inside or from outside of the
certain folder
but anyway, i've tried an example adding a hook handler, and it's called
only once:
https://github.com/bubenkoff/pytest-bdd-issue
are you sure you've checked and hooks called twice?
(bdd-issue)┌─[vagrant@paylogic-virtual] - [~/workspace/pytest-bdd-issue] -
[2014-09-11 07:54:46]
└─[1] <git:(master 498c1d✱✈) > py.test -s
test session starts
platform linux2 -- Python 2.7.6 -- py-1.4.24 -- pytest-2.6.2
plugins: bdd, bdd
foo.conftest
collecting 0 items
conftest
pytest_generate_tests hook
collected 1 items
foo/test_foo.py pytest_pyfunc_call hook
.
i'll think how to avoid this strange double collection anyway
On 11 September 2014 08:53, Robin Pedersen [email protected] wrote:
I run it without the 'foo' argument: py.test -s
—
Reply to this email directly or view it on GitHub
#62 (comment)
.
Anatoly Bubenkov
from pytest-bdd.
I added another conftest.py in the base directory. Now it's being called twice. We happen to have another conftest.py in our main project, for adding command line options that are "global" for all subdirectories.
For the simplified example, I only checked that the module was imported twice.
from pytest-bdd.
Btw, I have currently worked around this issue by separating all test files from python modules that are used as utilities in tests, and not having __init__.py
files in the directories that contain tests. I'm fine with this, because I like the separation anyway.
from pytest-bdd.
would you mind creating a PR with the test reproducing this problem?
So i can easily work on the actual fix
On 11/09/2014, Robin Pedersen [email protected] wrote:
Btw, I have currently worked around this issue by separating all test files
from python modules that are used as utilities in tests, and not having
__init__.py
files in the directories that contain tests. I'm fine with
this, because I like the separation anyway.
Reply to this email directly or view it on GitHub:
#62 (comment)
Anatoly Bubenkov
from pytest-bdd.
Related Issues (20)
- Step definition is not found when using Scenario Outline and "/" characters in the Examples HOT 6
- Step file generated from powershell throws error on collection - not UTF-8 encoded HOT 3
- Missing tag for 7.0.1 HOT 2
- RFE: is it possible to restart making github releases?🤔 HOT 2
- How to use multiple values for a parameter in Scenario Outline Examples
- Custom hooks HOT 1
- Issue with pytest-bdd Failing to Identify Correct Scenario Path After Folder Name Change HOT 2
- `iterparentnodeids` removed from pytest HOT 1
- Step definition parses wrong parameter from feature file
- Unable to run parallel tests with pytest-xdist - can't serialize <class 'pytest_bdd.parser.Step'> HOT 1
- Pytest emits deprecation warning: "A private pytest class or function was used" HOT 3
- pytest-bdd doesn't support pytest 8.1.0 HOT 5
- Missing git tags for 7.1 and 7.1.1 releases HOT 1
- Python 3.8/pytest 3.0.4/pytest-bdd 3.1.0 crash: TypeError: an integer is required (got type bytes) HOT 2
- Pytest 8.1.1 fixture injection compability HOT 2
- Unable to run pytest-bdd with pytest-xdist, can't serialize <class 'pytest_bdd.parser.Step'> HOT 4
- Does pytest-bdd support pytest-xdist? HOT 2
- Version 7.1.2 no longer provides pytest_bdd.steps.inject_fixture HOT 1
- Issue with existing working automation after python 3.11.1 and pytest-bdd 7.00 upgrade HOT 6
- Re-use of target_fixture not possible anymore HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytest-bdd.