From b3f369aa819003e4c8e5a12be116713abd2607ce Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 6 Jul 2015 12:38:45 -0700 Subject: [PATCH] tests for utils.joinModes so I don't break it in the future --- tests/test_utils.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_utils.py b/tests/test_utils.py index 45c0ea8..c68c820 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -2,6 +2,7 @@ import sys import os sys.path.append(os.getcwd()) import unittest +import itertools import utils @@ -58,5 +59,15 @@ class TestUtils(unittest.TestCase): self.assertTrue(utils.isServerName('pylink.overdrive.pw')) self.assertFalse(utils.isServerName(' i lost the game')) + def testJoinModes(self): + res = utils.joinModes({('l', '50'), ('n', None), ('t', None)}) + # Sets are orderless, so the end mode could be scrambled in a number of ways. + # Basically, we're looking for a string that looks like '+ntl 50' or '+lnt 50'. + possible = ['+%s 50' % ''.join(x) for x in itertools.permutations('lnt', 3)] + self.assertIn(res, possible) + # Without any arguments, make sure there is no trailing space. + self.assertEqual(utils.joinModes({('t', None)}), '+t') + self.assertEqual(utils.joinModes(set()), '+') + if __name__ == '__main__': unittest.main()