Comments (3)
I believe there was a fix for this in the 8 series
We should warn better about implicit indirect parameters having different scopes
from pytest.
I believe there was a fix for this in the 8 series
We should warn better about implicit indirect parameters having different scopes
I just tried with the latest version 8.0.2
and the issue exists in it.
from pytest.
Thank you for posting, @gjambaisivanandham. I'm new to pytest as well so I am interested in exploring and understanding your issue.
These may be silly remarks coming from my ignorance of session scope but:
- do your examples have syntax errors? It looks to me like
response
isn't defined in the body of your test functions, for example. - aren't you overriding the session fixture by directly parametrizing the test functions?
- to not override your session fixture, shouldn't
indirect=True
be used?
Is this the fixture usage your are expecting from file.py
below. Note that test_scenario_1
uses indirect=True
in my example.
import pytest
@pytest.fixture(scope='session')
def my_fixture(request):
"""I am being used."""
pass
@pytest.mark.parametrize('my_fixture', ['a','b'], indirect=True)
def test_scenario_1(my_fixture):
pass
@pytest.mark.parametrize('my_fixture', ['a','b'])
def test_scenario_2(my_fixture):
pass
Fixture usage:
$ pytest file.py --fixtures-per-test
-------------------------- fixtures used by test_scenario_1[a] ---------------------------
-------------------------------------- (file.py:10) --------------------------------------
my_fixture -- file.py:4
I am being used.
-------------------------- fixtures used by test_scenario_1[b] ---------------------------
-------------------------------------- (file.py:10) --------------------------------------
my_fixture -- file.py:4
I am being used.
-------------------------- fixtures used by test_scenario_2[a] ---------------------------
-------------------------------------- (file.py:14) --------------------------------------
my_fixture -- src/_pytest/python.py:1113
no docstring available
-------------------------- fixtures used by test_scenario_2[b] ---------------------------
-------------------------------------- (file.py:14) --------------------------------------
my_fixture -- src/_pytest/python.py:1113
no docstring available
- @RonnyPfannschmidt: are you saying the
parametrize
mark should implicitly do parametrization of the session fixture here rather than creating a pseudo fixture for the argumentmy_fixture
?
Thank you again, @gjambaisivanandham!
from pytest.
Related Issues (20)
- The teardown does not execute properly for session level fixture when we use --reruns HOT 5
- `--doctest-modules` option causes namespace packages' subpackages to be added to `sys.path` HOT 4
- pytest 8.2.0 runs `unittest.case.TestCase.__init__` during collecting phase in the same process HOT 6
- Support Dark Mode for Pytest Docs Website HOT 5
- Incorrect confcutdir inferred when rootdir is under a symlink directory
- Pytest 8.2.0: "AttributeError: 'VendorImporter' object has no attribute 'find_spec'" HOT 1
- Test collection to broad, walking sideways, causes PermissionError for tests in /tmp subdirs HOT 1
- pytest life cycle (fixture scoped session) HOT 1
- Found a possible security concern HOT 1
- Crashing under a squashfuse_ll read-only mount
- c85fce39b broke importing standard library modules that are "masked"
- Reordering tests with `pytest_collection_modifyitems` hook fails HOT 1
- 8.1.1 removed ability to introspect teardown exceptions in `pytest_fixture_post_finalizer` HOT 2
- Extra info in assertion is truncated even with `-vv` HOT 1
- Error: EACCES: permission denied, scandir .pytest_cache with 8.2.0 HOT 6
- Warn if collection spends >5s traversing a directory without collecting any tests HOT 1
- Test failures on Python 3.13.0b1 HOT 1
- Pytest 8 broke sorting for package-scoped fixtures HOT 1
- Trying to use mypy and pytest with a multiprocessing.Value - unable to use Synchronized as a type HOT 3
- Exit code is 1 when whole file fails, but 0 when individual tests fail HOT 2
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.