diff options
| author | 2019-11-14 20:16:23 +0100 | |
|---|---|---|
| committer | 2019-11-14 20:16:23 +0100 | |
| commit | eef447a2c4e237a56b8f3cb72ee3e4bc54e7961c (patch) | |
| tree | 3a0926c80abf689e45304f971842244f516d091f | |
| parent | Fix bug in attachments rule where last_message could potentially count twice ... (diff) | |
Adjust attachments rule unit test to correcty build the arguments for the tested rule
| -rw-r--r-- | tests/bot/rules/test_attachments.py | 18 | 
1 files changed, 11 insertions, 7 deletions
| diff --git a/tests/bot/rules/test_attachments.py b/tests/bot/rules/test_attachments.py index 770dd3201..a43741fcc 100644 --- a/tests/bot/rules/test_attachments.py +++ b/tests/bot/rules/test_attachments.py @@ -21,7 +21,9 @@ class AttachmentRuleTests(unittest.TestCase):              (msg(0),),          ) -        for last_message, *recent_messages in cases: +        for recent_messages in cases: +            last_message = recent_messages[0] +              with self.subTest(                  last_message=last_message,                  recent_messages=recent_messages @@ -39,14 +41,16 @@ class AttachmentRuleTests(unittest.TestCase):              ([msg(1)] * 6, 6),          ) -        for messages, total in cases: -            last_message, *recent_messages = messages -            relevant_messages = [last_message] + [ +        for recent_messages, total in cases: +            last_message = recent_messages[0] +            relevant_messages = tuple(                  msg                  for msg in recent_messages -                if msg.author == last_message.author -                and len(msg.attachments) > 0 -            ] +                if ( +                    msg.author == last_message.author +                    and len(msg.attachments) > 0 +                ) +            )              with self.subTest(                  last_message=last_message, | 
