Skip to content

Commit 82bf96a

Browse files
committed
remove console width
Signed-off-by: sirutBuasai <sirutbuasai27@outlook.com>
1 parent f0b12ca commit 82bf96a

File tree

2 files changed

+7
-38
lines changed

2 files changed

+7
-38
lines changed

test/conftest.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ def image_uri(request):
3131

3232

3333
def pytest_configure():
34-
"""Set up rich logging for all tests"""
34+
"""
35+
Set up rich logging for all tests
36+
To use rich logging in each tests,
37+
include `logger` fixture in the test argument.
38+
"""
3539
# Install rich traceback handling
3640
install(show_locals=True)
3741

@@ -50,12 +54,13 @@ def pytest_configure():
5054
)
5155

5256
# Create console with theme
53-
console = Console(theme=custom_theme, force_terminal=True)
57+
console = Console(theme=custom_theme, force_terminal=True, tab_size=2)
5458

5559
# Configure Rich handler
5660
rich_handler = RichHandler(
5761
console=console,
5862
rich_tracebacks=True,
63+
tracebacks_code_width=None,
5964
tracebacks_show_locals=True,
6065
show_time=True,
6166
show_path=True,
@@ -75,5 +80,4 @@ def pytest_configure():
7580

7681
@pytest.fixture(scope="session")
7782
def logger():
78-
"""Fixture to provide logger for tests"""
7983
return logging.getLogger()

test/test_example.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import time
22

33
import pytest
4-
from rich import print as rprint
5-
from rich.progress import track
6-
from rich.table import Table
74

85

96
def test_basic_logging(logger):
@@ -20,38 +17,6 @@ def test_basic_logging(logger):
2017
logger.info("Test completed successfully")
2118

2219

23-
def test_with_rich_table(logger):
24-
"""Test using rich table with logging"""
25-
logger.info("Starting table test")
26-
27-
# Create and display a rich table
28-
table = Table(title="Test Results")
29-
table.add_column("Test Case", style="cyan")
30-
table.add_column("Status", style="green")
31-
table.add_column("Duration", style="blue")
32-
33-
table.add_row("Login Test", "✅ Passed", "0.5s")
34-
table.add_row("API Test", "✅ Passed", "1.2s")
35-
36-
rprint(table)
37-
logger.info("Table test completed")
38-
39-
40-
def test_with_progress(logger):
41-
"""Test with progress tracking"""
42-
logger.info("Starting progress test")
43-
44-
# Simulate work with progress tracking
45-
results = []
46-
for i in track(range(5), description="Processing items..."):
47-
time.sleep(0.2)
48-
results.append(i)
49-
logger.debug(f"Processed item {i}")
50-
51-
assert len(results) == 5
52-
logger.info("Progress test completed")
53-
54-
5520
@pytest.mark.parametrize("input,expected", [(2, 4), (3, 9), (4, 16)])
5621
def test_parametrized(logger, input, expected):
5722
"""Parametrized test with logging"""

0 commit comments

Comments
 (0)