MCPcopy
hub / github.com/pytest-dev/pytest / extract_from

Method extract_from

src/_pytest/mark/structures.py:138–163  ·  view source on GitHub ↗

Extract from an object or objects. :param parameterset: A legacy style parameterset that may or may not be a tuple, and may or may not be wrapped into a mess of mark objects. :param force_tuple: Enforce tuple wrapping so single argument tuple val

(
        cls,
        parameterset: ParameterSet | Sequence[object] | object,
        force_tuple: bool = False,
    )

Source from the content-addressed store, hash-verified

136
137 @classmethod
138 def extract_from(
139 cls,
140 parameterset: ParameterSet | Sequence[object] | object,
141 force_tuple: bool = False,
142 ) -> ParameterSet:
143 """Extract from an object or objects.
144
145 :param parameterset:
146 A legacy style parameterset that may or may not be a tuple,
147 and may or may not be wrapped into a mess of mark objects.
148
149 :param force_tuple:
150 Enforce tuple wrapping so single argument tuple values
151 don't get decomposed and break tests.
152 """
153 if isinstance(parameterset, cls):
154 return parameterset
155 if force_tuple:
156 return cls.param(parameterset)
157 else:
158 # TODO: Refactor to fix this type-ignore. Currently the following
159 # passes type-checking but crashes:
160 #
161 # @pytest.mark.parametrize(('x', 'y'), [1, 2])
162 # def test_foo(x, y): pass
163 return cls(parameterset, marks=[], id=None) # type: ignore[arg-type]
164
165 @staticmethod
166 def _parse_parametrize_args(

Callers 1

Calls 2

clsFunction · 0.85
paramMethod · 0.80

Tested by

no test coverage detected