MCPcopy Create free account
hub / github.com/pytest-dev/pytest / extract_from

Method extract_from

src/_pytest/mark/structures.py:104–130  ·  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: Union["ParameterSet", Sequence[object], object],
        force_tuple: bool = False,
    )

Source from the content-addressed store, hash-verified

102
103 @classmethod
104 def extract_from(
105 cls,
106 parameterset: Union["ParameterSet", Sequence[object], object],
107 force_tuple: bool = False,
108 ) -> "ParameterSet":
109 """Extract from an object or objects.
110
111 :param parameterset:
112 A legacy style parameterset that may or may not be a tuple,
113 and may or may not be wrapped into a mess of mark objects.
114
115 :param force_tuple:
116 Enforce tuple wrapping so single argument tuple values
117 don't get decomposed and break tests.
118 """
119
120 if isinstance(parameterset, cls):
121 return parameterset
122 if force_tuple:
123 return cls.param(parameterset)
124 else:
125 # TODO: Refactor to fix this type-ignore. Currently the following
126 # passes type-checking but crashes:
127 #
128 # @pytest.mark.parametrize(('x', 'y'), [1, 2])
129 # def test_foo(x, y): pass
130 return cls(parameterset, marks=[], id=None) # type: ignore[arg-type]
131
132 @staticmethod
133 def _parse_parametrize_args(

Callers 1

Calls 2

clsFunction · 0.85
paramMethod · 0.80

Tested by

no test coverage detected