(self)
| 84 | metafunc.parametrize("y", [5, 6], ids=42) # type: ignore[arg-type] |
| 85 | |
| 86 | def test_parametrize_error_iterator(self) -> None: |
| 87 | def func(x): |
| 88 | raise NotImplementedError() |
| 89 | |
| 90 | class Exc(Exception): |
| 91 | def __repr__(self): |
| 92 | return "Exc(from_gen)" |
| 93 | |
| 94 | def gen() -> Iterator[Union[int, None, Exc]]: |
| 95 | yield 0 |
| 96 | yield None |
| 97 | yield Exc() |
| 98 | |
| 99 | metafunc = self.Metafunc(func) |
| 100 | # When the input is an iterator, only len(args) are taken, |
| 101 | # so the bad Exc isn't reached. |
| 102 | metafunc.parametrize("x", [1, 2], ids=gen()) # type: ignore[arg-type] |
| 103 | assert [(x.funcargs, x.id) for x in metafunc._calls] == [ |
| 104 | ({"x": 1}, "0"), |
| 105 | ({"x": 2}, "2"), |
| 106 | ] |
| 107 | with pytest.raises( |
| 108 | fail.Exception, |
| 109 | match=( |
| 110 | r"In func: ids must be list of string/float/int/bool, found:" |
| 111 | r" Exc\(from_gen\) \(type: <class .*Exc'>\) at index 2" |
| 112 | ), |
| 113 | ): |
| 114 | metafunc.parametrize("x", [1, 2, 3], ids=gen()) # type: ignore[arg-type] |
| 115 | |
| 116 | def test_parametrize_bad_scope(self) -> None: |
| 117 | def func(x): |
nothing calls this directly
no test coverage detected