@@ -4108,54 +4108,34 @@ def test_fixture_named_request(testdir):
4108
4108
4109
4109
def test_fixture_duplicated_arguments (testdir ):
4110
4110
"""Raise error if there are positional and keyword arguments for the same parameter (#1682)."""
4111
- testdir .makepyfile (
4112
- """
4113
- import pytest
4111
+ with pytest .raises (TypeError ) as excinfo :
4114
4112
4115
- with pytest.raises(TypeError) as excinfo:
4116
-
4117
- @pytest.fixture("session", scope="session")
4118
- def arg(arg):
4119
- pass
4120
-
4121
- def test_error():
4122
- assert (
4123
- str(excinfo.value)
4124
- == "The fixture arguments are defined as positional and keyword: scope. "
4125
- "Use only keyword arguments."
4126
- )
4113
+ @pytest .fixture ("session" , scope = "session" )
4114
+ def arg (arg ):
4115
+ pass
4127
4116
4128
- """
4117
+ assert (
4118
+ str (excinfo .value )
4119
+ == "The fixture arguments are defined as positional and keyword: scope. "
4120
+ "Use only keyword arguments."
4129
4121
)
4130
4122
4131
- reprec = testdir .inline_run ()
4132
- reprec .assertoutcome (passed = 1 )
4133
-
4134
4123
4135
4124
def test_fixture_with_positionals (testdir ):
4136
4125
"""Raise warning, but the positionals should still works (#1682)."""
4137
- testdir .makepyfile (
4138
- """
4139
- import os
4126
+ from _pytest .deprecated import FIXTURE_POSITIONAL_ARGUMENTS
4140
4127
4141
- import pytest
4142
- from _pytest.deprecated import FIXTURE_POSITIONAL_ARGUMENTS
4128
+ with pytest .warns (pytest .PytestDeprecationWarning ) as warnings :
4143
4129
4144
- with pytest.warns(pytest.PytestDeprecationWarning) as warnings:
4145
- @pytest.fixture("function", [0], True)
4146
- def arg(monkeypatch):
4147
- monkeypatch.setenv("AUTOUSE_WORKS", "1")
4130
+ @pytest .fixture ("function" , [0 ], True )
4131
+ def arg (monkeypatch ):
4132
+ monkeypatch .setenv ("AUTOUSE_WORKS" , "1" )
4148
4133
4134
+ assert str (warnings [0 ].message ) == str (FIXTURE_POSITIONAL_ARGUMENTS )
4149
4135
4150
- def test_autouse():
4151
- assert os.environ.get("AUTOUSE_WORKS") == "1"
4152
- assert str(warnings[0].message) == str(FIXTURE_POSITIONAL_ARGUMENTS)
4153
-
4154
- """
4155
- )
4156
-
4157
- reprec = testdir .inline_run ()
4158
- reprec .assertoutcome (passed = 1 )
4136
+ assert arg ._pytestfixturefunction .scope == "function"
4137
+ assert arg ._pytestfixturefunction .params == (0 ,)
4138
+ assert arg ._pytestfixturefunction .autouse
4159
4139
4160
4140
4161
4141
def test_indirect_fixture_does_not_break_scope (testdir ):
0 commit comments