1"""
2The one error for a test that is written in a way the runner can't run.
3"""
4
5__all__ = ["TestDefinitionError"]
6
7
8class TestDefinitionError(Exception):
9 """
10 A test, or something the runner reads beside it, is written in a way
11 that can't be run: a second `@cases`, a `@skip` with no reason, a
12 parameter nothing passes in, a test that yields, a `tests/lifecycle.py`
13 that declares no lifecycle.
14
15 Its message says what is wrong and what to write instead, so the runner
16 prints the message on its own. Any other error met while reading a test
17 file is printed with its traceback.
18
19 `line` is the line of the file the message is about, when it is about
20 one line.
21 """
22
23 def __init__(self, message: str, *, line: int | None = None) -> None:
24 super().__init__(message)
25 self.line = line