diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2020-06-07 23:57:15 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2020-06-16 23:03:01 +0200 |
commit | e6446b84db52d9c5b6adf6c8869ab3d12e6f2ce4 (patch) | |
tree | f44f371c7c7fb5def5b6cf0cb528e8aa73c10e9f /_pytest | |
parent | 7a4a95baafc78682288acaa1b4622d87eed1db3e (diff) | |
download | wee-slack-e6446b84db52d9c5b6adf6c8869ab3d12e6f2ce4.tar.gz |
Support colorizing attachment prefix or line
Thanks to @Informatic for the initial implementation of this in PR #426.
I have seen that most attachment colors are without the leading #, but a
few does include it, so we have to handle it.
Fixes #424, closes #426
Diffstat (limited to '_pytest')
-rw-r--r-- | _pytest/conftest.py | 5 | ||||
-rw-r--r-- | _pytest/test_unwrap_attachments.py | 20 |
2 files changed, 25 insertions, 0 deletions
diff --git a/_pytest/conftest.py b/_pytest/conftest.py index ad0949e..1ad2310 100644 --- a/_pytest/conftest.py +++ b/_pytest/conftest.py @@ -117,6 +117,11 @@ class FakeWeechat(): return "" def color(self, name): return "<[color {}]>".format(name) + def info_get(self, info_name, arguments): + if info_name == "color_rgb2term": + return arguments + else: + return "" def __getattr__(self, name): def method(*args): pass diff --git a/_pytest/test_unwrap_attachments.py b/_pytest/test_unwrap_attachments.py index ea3a35d..054c0af 100644 --- a/_pytest/test_unwrap_attachments.py +++ b/_pytest/test_unwrap_attachments.py @@ -267,6 +267,26 @@ import pytest "| Second attachment text", ]), }, + { + 'input_message': {'attachments': [{ + 'title': 'Title', + 'color': 'ff0000', + }]}, + 'input_text_before': "", + 'output': "\n".join([ + "<[color 16711680]>|<[color reset]> Title", + ]), + }, + { + 'input_message': {'attachments': [{ + 'title': 'Title', + 'color': '#ff0000', + }]}, + 'input_text_before': "", + 'output': "\n".join([ + "<[color 16711680]>|<[color reset]> Title", + ]), + }, )) def test_unwrap_attachments(case): result = wee_slack.unwrap_attachments( |