aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-05-25 21:07:21 -0700
committerGravatar MarkKoz <[email protected]>2020-05-25 21:07:21 -0700
commit19cc849d4c70bc3e792460ad712aa308fa500462 (patch)
tree0767a79338583da22210ff131cc78a522d1c5ba9
parentFix valid token regex test (diff)
Fix multiple match text for token regex
It has to account for the addition of groups. It's easiest to compare the entire string so `finditer` is used to return re.Match objects; the tuples of `findall` would be cumbersome. Also threw in a change to use `assertCountEqual` cause the order doesn't really matter.
-rw-r--r--tests/bot/cogs/test_token_remover.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/bot/cogs/test_token_remover.py b/tests/bot/cogs/test_token_remover.py
index 518bf91ca..2ecfae2bd 100644
--- a/tests/bot/cogs/test_token_remover.py
+++ b/tests/bot/cogs/test_token_remover.py
@@ -174,8 +174,9 @@ class TokenRemoverTests(unittest.IsolatedAsyncioTestCase):
tokens = ["x.y.z", "a.b.c"]
message = f"garbage {tokens[0]} hello {tokens[1]} world"
- results = token_remover.TOKEN_RE.findall(message)
- self.assertEqual(tokens, results)
+ results = token_remover.TOKEN_RE.finditer(message)
+ results = [match[0] for match in results]
+ self.assertCountEqual(tokens, results)
@autospec(TokenRemover, "is_valid_user_id", "is_valid_timestamp")
def test_is_maybe_token_missing_part_returns_false(self, valid_user, valid_time):