From 691f2f86ee7e1f3e109b073232588d29dbf84a9e Mon Sep 17 00:00:00 2001 From: tligui_y Date: Tue, 5 Aug 2025 14:18:46 +0200 Subject: [PATCH] Update tests/test_utils_richcfg.py --- tests/test_utils_richcfg.py | 46 ++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/tests/test_utils_richcfg.py b/tests/test_utils_richcfg.py index 12e87c0b7..fbf0ba38e 100644 --- a/tests/test_utils_richcfg.py +++ b/tests/test_utils_richcfg.py @@ -81,17 +81,41 @@ def test_rich_inspector_outputs_more_than_builtin(monkeypatch): print('\n\n\n', file=sys.__stdout__) print(builtin_text, file=sys.__stdout__) - # Comparison assertions: Rich adds structure and content - # Rich has sections and decoration - assert "╭" in rich_text or "┌" in rich_text # Decorative borders - assert "Attributes" in rich_text or "attribute" in rich_text.lower() - assert "Returns a welcome message." in rich_text - assert "Returns a welcome message." not in builtin_text + # Rich output: shows actual instance content + # Rich shows live instance attribute values like: + # age = 30 + # name = 'Alice' + # role = 'admin' + assert "age = 30" in rich_text + assert "name = 'Alice'" in rich_text + assert "role = 'admin'" in rich_text - # Both include method names and basic info - assert "greet" in rich_text - assert "greet" in builtin_text - assert "name" in rich_text - assert "name" in builtin_text + # Built-in inspector does NOT show instance values + assert "30" not in builtin_text + assert "Alice" not in builtin_text + assert "admin" not in builtin_text + + # # Built-in inspector only shows the brut init function + assert "def __init__(self, name: str, age: int):" in builtin_text + assert "self.name = name" in builtin_text + assert "self.age = age" in builtin_text + + + # Both outputs include the same method and documentation + + # Method name is visible in both + assert "def greet():" in rich_text + assert "def greet(self):" in builtin_text + + # Method docstring is visible in both + assert "Returns a welcome message." in rich_text + assert "Returns a welcome message." in builtin_text + + # Class docstring is shown in both assert "Represents a user in the system." in rich_text assert "Represents a user in the system." in builtin_text + + # Structural difference: Rich wraps values in a visual box + assert "╭─ user =" and "─╮" and "╰─" and "─╯" in rich_text + assert rich_text.count("│") >= 10 +