mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-25 12:12:53 +01:00
tests for utils.joinModes so I don't break it in the future
This commit is contained in:
parent
74339d1038
commit
b3f369aa81
@ -2,6 +2,7 @@ import sys
|
|||||||
import os
|
import os
|
||||||
sys.path.append(os.getcwd())
|
sys.path.append(os.getcwd())
|
||||||
import unittest
|
import unittest
|
||||||
|
import itertools
|
||||||
|
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
@ -58,5 +59,15 @@ class TestUtils(unittest.TestCase):
|
|||||||
self.assertTrue(utils.isServerName('pylink.overdrive.pw'))
|
self.assertTrue(utils.isServerName('pylink.overdrive.pw'))
|
||||||
self.assertFalse(utils.isServerName(' i lost the game'))
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user