Debian Codegraph @

tests/test_coverup_75.py

raw symbols SCIP
1 # file scalene/syntaxline.py:7-14
2 # lines [7, 8, 9, 11, 12, 13, 14]
3 # branches []
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 # Create a temporary file to ensure the test environment is clean
29 temp_file = tmp_path / "temp.txt"
30 temp_file.write_text("temporary file content")
31 assert temp_file.exists()
32
33 # Run the test
34 test_rich_console(console, segments)
35
36 # Clean up by removing the temporary file
37 temp_file.unlink()
38 assert not temp_file.exists()