From a3479b618da87f5f6eca6ba490d98ba84a3573ba Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Thu, 30 Oct 2014 14:07:41 -0400 Subject: [PATCH] Tests --- glue.py | 3 +++ tests.py | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests.py diff --git a/glue.py b/glue.py index d35e5c9..1f75332 100644 --- a/glue.py +++ b/glue.py @@ -1,4 +1,7 @@ +from collections import OrderedDict + def glue(*args, **kwargs): 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 return " ".join(what_to_glue) diff --git a/tests.py b/tests.py new file mode 100644 index 0000000..1c65029 --- /dev/null +++ b/tests.py @@ -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()