|
3 | 3 |
|
4 | 4 | import attr |
5 | 5 | import pytest |
| 6 | +from _pytask.console import _get_file |
| 7 | +from _pytask.console import _get_source_lines |
6 | 8 | from _pytask.console import console |
7 | 9 | from _pytask.console import create_summary_panel |
8 | 10 | from _pytask.console import create_url_style_for_path |
|
19 | 21 | from rich.text import Span |
20 | 22 | from rich.text import Text |
21 | 23 |
|
| 24 | +from tests._test_console_helpers import empty_decorator |
| 25 | + |
22 | 26 |
|
23 | 27 | def task_func(): |
24 | 28 | ... |
@@ -185,3 +189,36 @@ def test_format_task_id( |
185 | 189 |
|
186 | 190 | result = format_task_id(task, editor_url_scheme, use_short_name, relative_to) |
187 | 191 | assert result == expected |
| 192 | + |
| 193 | + |
| 194 | +@pytest.mark.parametrize( |
| 195 | + "task_func, skipped_paths, expected", |
| 196 | + [ |
| 197 | + (task_func, [], _THIS_FILE), |
| 198 | + ( |
| 199 | + empty_decorator(task_func), |
| 200 | + [], |
| 201 | + _THIS_FILE.parent.joinpath("_test_console_helpers.py"), |
| 202 | + ), |
| 203 | + ( |
| 204 | + empty_decorator(task_func), |
| 205 | + [_THIS_FILE.parent.joinpath("_test_console_helpers.py")], |
| 206 | + _THIS_FILE, |
| 207 | + ), |
| 208 | + ], |
| 209 | +) |
| 210 | +def test_get_file(task_func, skipped_paths, expected): |
| 211 | + result = _get_file(task_func, skipped_paths) |
| 212 | + assert result == expected |
| 213 | + |
| 214 | + |
| 215 | +@pytest.mark.parametrize( |
| 216 | + "task_func, expected", |
| 217 | + [ |
| 218 | + (task_func, _SOURCE_LINE_TASK_FUNC), |
| 219 | + (empty_decorator(task_func), _SOURCE_LINE_TASK_FUNC), |
| 220 | + ], |
| 221 | +) |
| 222 | +def test_get_source_lines(task_func, expected): |
| 223 | + result = _get_source_lines(task_func) |
| 224 | + assert result == expected |
0 commit comments