Update tests/test_utils_richcfg.py
Run CI Tests / test (push) Successful in 2m40s

This commit is contained in:
2025-08-05 14:18:46 +02:00
parent f649d813f0
commit 691f2f86ee
+35 -11
View File
@@ -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