| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
import pytest |
| 6 |
from scalene.syntaxline import SyntaxLine |
| 7 |
from rich.console import Console |
| 8 |
from rich.segment import Segment |
| 9 |
|
| 10 |
|
| 11 |
@pytest.fixture |
| 12 |
def console(): |
| 13 |
return Console() |
| 14 |
|
| 15 |
|
| 16 |
@pytest.fixture |
| 17 |
def segments(): |
| 18 |
return [Segment("test"), Segment(" line")] |
| 19 |
|
| 20 |
|
| 21 |
def test_rich_console(console, segments): |
| 22 |
syntax_line = SyntaxLine(segments) |
| 23 |
result = list(syntax_line.__rich_console__(console, None)) |
| 24 |
assert result == segments |
| 25 |
|
| 26 |
|
| 27 |
def test_cleanup(console, segments, tmp_path): |
| 28 |
|
| 29 |
temp_file = tmp_path / "temp.txt" |
| 30 |
temp_file.write_text("temporary file content") |
| 31 |
assert temp_file.exists() |
| 32 |
|
| 33 |
|
| 34 |
test_rich_console(console, segments) |
| 35 |
|
| 36 |
|
| 37 |
temp_file.unlink() |
| 38 |
assert not temp_file.exists() |