(self)
| 139 | metafunc.parametrize("y", [5, 6], ids=42) # type: ignore[arg-type] |
| 140 | |
| 141 | def test_parametrize_error_iterator(self) -> None: |
| 142 | def func(x): |
| 143 | raise NotImplementedError() |
| 144 | |
| 145 | class Exc(Exception): |
| 146 | def __repr__(self): |
| 147 | return "Exc(from_gen)" |
| 148 | |
| 149 | def gen() -> Iterator[int | None | Exc]: |
| 150 | yield 0 |
| 151 | yield None |
| 152 | yield Exc() |
| 153 | |
| 154 | metafunc = self.Metafunc(func) |
| 155 | # When the input is an iterator, only len(args) are taken, |
| 156 | # so the bad Exc isn't reached. |
| 157 | metafunc.parametrize("x", [1, 2], ids=gen()) |
| 158 | assert [(x.params, x.id) for x in metafunc._calls] == [ |
| 159 | ({"x": 1}, "0"), |
| 160 | ({"x": 2}, "2"), |
| 161 | ] |
| 162 | with pytest.raises( |
| 163 | fail.Exception, |
| 164 | match=( |
| 165 | r"In mock::nodeid: ids contains unsupported value Exc\(from_gen\) \(type: <class .*Exc'>\) at index 2. " |
| 166 | r"Supported types are: .*" |
| 167 | ), |
| 168 | ): |
| 169 | metafunc.parametrize("x", [1, 2, 3], ids=gen()) |
| 170 | |
| 171 | def test_parametrize_bad_scope(self) -> None: |
| 172 | def func(x): |
nothing calls this directly
no test coverage detected