Tests
This commit is contained in:
parent
fa4b3396b6
commit
a3479b618d
3
glue.py
3
glue.py
@ -1,4 +1,7 @@
|
|||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
def glue(*args, **kwargs):
|
def glue(*args, **kwargs):
|
||||||
what_to_glue = list(args)
|
what_to_glue = list(args)
|
||||||
|
kwargs = OrderedDict(sorted(kwargs.items(), key=lambda t: t[0])) # I dont care what order you submit them in, they will be alphabetical
|
||||||
what_to_glue.extend([v for k,v in kwargs.iteritems()]) # Ignore all your keys, because you're doing this wrong anyway
|
what_to_glue.extend([v for k,v in kwargs.iteritems()]) # Ignore all your keys, because you're doing this wrong anyway
|
||||||
return " ".join(what_to_glue)
|
return " ".join(what_to_glue)
|
||||||
|
24
tests.py
Normal file
24
tests.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import unittest
|
||||||
|
from glue import glue
|
||||||
|
|
||||||
|
|
||||||
|
class GlueTests(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def test_tuple(self):
|
||||||
|
output = glue("why", "would", "you", "run", "these", "tests")
|
||||||
|
assert output == "why would you run these tests"
|
||||||
|
|
||||||
|
def test_tuple_and_named(self):
|
||||||
|
output = glue("why", "would", "you", "run", "these", "tests", who="bozo")
|
||||||
|
assert output == "why would you run these tests bozo"
|
||||||
|
|
||||||
|
def test_named(self):
|
||||||
|
output = glue(what="bozo", who="clown")
|
||||||
|
print output
|
||||||
|
assert output == "bozo clown"
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
Loading…
Reference in New Issue
Block a user