diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2020-06-08 00:29:08 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2020-06-14 22:19:15 +0200 |
commit | 7a4a95baafc78682288acaa1b4622d87eed1db3e (patch) | |
tree | 54f90bfc95045d6ad1b9ab961bede47be4282c7e /_pytest | |
parent | 8ca00d735279e78e759e72c6dff4c17fa43405d5 (diff) | |
download | wee-slack-7a4a95baafc78682288acaa1b4622d87eed1db3e.tar.gz |
Assert color values in tests
Diffstat (limited to '_pytest')
-rw-r--r-- | _pytest/conftest.py | 2 | ||||
-rw-r--r-- | _pytest/test_formatting.py | 6 | ||||
-rw-r--r-- | _pytest/test_process_message.py | 3 | ||||
-rw-r--r-- | _pytest/test_thread.py | 4 |
4 files changed, 10 insertions, 5 deletions
diff --git a/_pytest/conftest.py b/_pytest/conftest.py index b49388d..ad0949e 100644 --- a/_pytest/conftest.py +++ b/_pytest/conftest.py @@ -116,7 +116,7 @@ class FakeWeechat(): def config_string(self, key): return "" def color(self, name): - return "" + return "<[color {}]>".format(name) def __getattr__(self, name): def method(*args): pass diff --git a/_pytest/test_formatting.py b/_pytest/test_formatting.py index 74dffba..4f6daa2 100644 --- a/_pytest/test_formatting.py +++ b/_pytest/test_formatting.py @@ -1,6 +1,7 @@ from __future__ import print_function, unicode_literals import pytest +import re import wee_slack @@ -26,4 +27,7 @@ def test_does_not_format(realish_eventrouter, text): "`* * * * * *`", ]) def test_preserves_format_chars_in_code(realish_eventrouter, text): - assert wee_slack.render_formatting(text) == text + formatted_text = wee_slack.render_formatting(text) + # TODO: wee-slack erroneously inserts formatting in code blocks + formatted_text = re.sub(r'<\[color .*?\]>', '', formatted_text) + assert formatted_text == text diff --git a/_pytest/test_process_message.py b/_pytest/test_process_message.py index 1a1ab37..b6d8ab6 100644 --- a/_pytest/test_process_message.py +++ b/_pytest/test_process_message.py @@ -45,4 +45,5 @@ def test_process_message(realish_eventrouter, team, user_alice): deleted_message_channel = team.channels['G3ZGMF4RZ'] deleted_message_ts = SlackTS('1485975698.000002') assert list(deleted_message_channel.messages.keys()) == [deleted_message_ts] - assert deleted_message_channel.messages[deleted_message_ts].message_json['text'] == '(deleted)' + deleted_str = '<[color red]>(deleted)<[color reset]>' + assert deleted_message_channel.messages[deleted_message_ts].message_json['text'] == deleted_str diff --git a/_pytest/test_thread.py b/_pytest/test_thread.py index 6567065..4095e77 100644 --- a/_pytest/test_thread.py +++ b/_pytest/test_thread.py @@ -25,7 +25,7 @@ def test_message_has_thread_suffix(realish_eventrouter, team, channel_general): realish_eventrouter.handle_next() message_text = channel_general.messages[thread_ts].message_json['_rendered_text'] - assert message_text == 'generally, yep! [ Thread: 309 Replies: 1 ]' + assert message_text == 'generally, yep! <[color lightcyan]>[ Thread: 309 Replies: 1 ]<[color reset]>' datafile = '_pytest/data/websocket/1485975842.1-message.json' data = json.loads(open(datafile).read()) @@ -34,4 +34,4 @@ def test_message_has_thread_suffix(realish_eventrouter, team, channel_general): realish_eventrouter.handle_next() message_text = channel_general.messages[thread_ts].message_json['_rendered_text'] - assert message_text == 'generally, yep! [ Thread: 309 Replies: 2 ]' + assert message_text == 'generally, yep! <[color lightcyan]>[ Thread: 309 Replies: 2 ]<[color reset]>' |