Improve test for messageview timeout

This commit is contained in:
Florian Bruhin 2017-07-11 09:25:53 +02:00
parent 7da6908850
commit 1e58c87380

View File

@ -104,12 +104,17 @@ def test_changing_timer_with_messages_shown(qtbot, view, config_stub):
config_stub.set('ui', 'message-timeout', 100)
@pytest.mark.parametrize('count', [1, 2, 3, 4, 5, 6, 7])
def test_show_messages_longer_when_there_are_multiple_of_them(view, config_stub, count):
"""When there are multiple messages, messages should be shown longer than usual. but with an upper maximum of 5"""
@pytest.mark.parametrize('count, expected', [(1, 100), (3, 300),
(5, 500), (7, 500)])
def test_show_multiple_messages_longer(view, count, expected):
"""When there are multiple messages, messages should be shown longer.
There is an upper maximum to avoid messages never disappearing.
"""
for message_number in range(1, count+1):
view.show_message(usertypes.MessageLevel.info, 'test ' + str(message_number))
assert view._clear_timer.interval() == min(5, count) * config_stub['ui']['message-timeout']
view.show_message(usertypes.MessageLevel.info,
'test ' + str(message_number))
assert view._clear_timer.interval() == expected
@pytest.mark.parametrize('replace1, replace2, length', [