|
11 | 11 | from mkdocstrings_handlers.python import rendering |
12 | 12 |
|
13 | 13 |
|
14 | | -def test_format_code_and_signature() -> None: |
15 | | - """Assert code and signatures can be Black-formatted.""" |
16 | | - assert rendering.do_format_code("print('Hello')", 100) |
17 | | - assert rendering.do_format_code('print("Hello")', 100) |
18 | | - assert rendering.do_format_signature("(param: str = 'hello') -> 'Class'", 100) |
19 | | - assert rendering.do_format_signature('(param: str = "hello") -> "Class"', 100) |
| 14 | +@pytest.mark.parametrize( |
| 15 | + "code", |
| 16 | + [ |
| 17 | + "print('Hello')", |
| 18 | + "aaaaa(bbbbb, ccccc=1) + ddddd.eeeee[ffff] or {ggggg: hhhhh, iiiii: jjjjj}", |
| 19 | + ], |
| 20 | +) |
| 21 | +def test_format_code(code: str) -> None: |
| 22 | + """Assert code can be Black-formatted. |
| 23 | +
|
| 24 | + Parameters: |
| 25 | + code: Code to format. |
| 26 | + """ |
| 27 | + for length in (5, 100): |
| 28 | + assert rendering.do_format_code(code, length) |
| 29 | + |
| 30 | + |
| 31 | +@pytest.mark.parametrize( |
| 32 | + "signature", |
| 33 | + ["Class.method(param: str = 'hello') -> 'OtherClass'"], |
| 34 | +) |
| 35 | +def test_format_signature(signature: str) -> None: |
| 36 | + """Assert signatures can be Black-formatted. |
| 37 | +
|
| 38 | + Parameters: |
| 39 | + signature: Signature to format. |
| 40 | + """ |
| 41 | + for length in (5, 100): |
| 42 | + assert rendering.do_format_signature(signature, length) |
20 | 43 |
|
21 | 44 |
|
22 | 45 | @dataclass |
|
0 commit comments