Closed mmartinortiz closed 2 months ago
Text objects have markup
attribute which returns the equivalent console markup.
Thanks,
That is exactly what I was looking for. As reference, this is how the test would look like:
def test_greetings():
assert greetings("Jon").markup == "Hello [blue]Jon[/blue]"
I hope we solved your problem.
If you like using Rich, you might also enjoy Textual
Hi,
I'd like to test that a
Text
object is rendered in a specific way. For example, given the following function:I would like to write a test that makes sure that the format is as expected, kind of:
Looking into possible solution I found this suggestion about capturing the output. In that case, I can compare with something like
Hello\x1b[34m Jon\x1b[0m\n
, but I find this a bit cryptic for a test.