ENH: Improve warning stacklevel
This commit is contained in:
parent
51ee3880c7
commit
3efcff8bd1
|
@ -0,0 +1 @@
|
||||||
|
Fix the ``stacklevel`` used when warning about marks used on fixtures.
|
|
@ -1192,7 +1192,7 @@ class FixtureFunctionMarker:
|
||||||
)
|
)
|
||||||
|
|
||||||
if hasattr(function, "pytestmark"):
|
if hasattr(function, "pytestmark"):
|
||||||
warnings.warn(MARKED_FIXTURE, stacklevel=2)
|
warnings.warn(MARKED_FIXTURE, stacklevel=4)
|
||||||
|
|
||||||
function = wrap_function_to_error_out_if_called_directly(function, self)
|
function = wrap_function_to_error_out_if_called_directly(function, self)
|
||||||
|
|
||||||
|
|
|
@ -185,6 +185,8 @@ def test_fixture_disallow_on_marked_functions():
|
||||||
# from applying @fixture twice
|
# from applying @fixture twice
|
||||||
# ValueError("fixture is being applied more than once to the same function")
|
# ValueError("fixture is being applied more than once to the same function")
|
||||||
assert len(record) == 1
|
assert len(record) == 1
|
||||||
|
# should point to this file
|
||||||
|
assert record[0].filename == __file__
|
||||||
|
|
||||||
|
|
||||||
def test_fixture_disallow_marks_on_fixtures():
|
def test_fixture_disallow_marks_on_fixtures():
|
||||||
|
|
Loading…
Reference in New Issue