stringify, and such
This commit is contained in:
parent
15b0977ab6
commit
53b081bc75
|
@ -7,6 +7,9 @@ any number of things together
|
|||
|
||||
>>> print glue("any","number","of","things","together",where="anywhere")
|
||||
any number of things together anywhere
|
||||
|
||||
>>> print glue("any","number","of","things","together", "even",["nested","lists"]])
|
||||
any number of things together even nested lists
|
||||
```
|
||||
|
||||
#Protip
|
||||
|
@ -17,8 +20,8 @@ You should probably just use [str.join](https://docs.python.org/2/library/stdtyp
|
|||
```
|
||||
Name Stmts Miss Cover Missing
|
||||
-------------------------------------
|
||||
glue 13 0 100%
|
||||
tests 20 0 100%
|
||||
glue 14 0 100%
|
||||
tests 24 0 100%
|
||||
-------------------------------------
|
||||
TOTAL 33 0 100%
|
||||
TOTAL 38 0 100%
|
||||
```
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Name Stmts Miss Cover Missing
|
||||
-------------------------------------
|
||||
glue 13 0 100%
|
||||
tests 20 0 100%
|
||||
glue 14 0 100%
|
||||
tests 24 0 100%
|
||||
-------------------------------------
|
||||
TOTAL 33 0 100%
|
||||
TOTAL 38 0 100%
|
||||
|
|
1
glue.py
1
glue.py
|
@ -12,4 +12,5 @@ def glue(*args, **kwargs):
|
|||
kwargs = collections.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 = flatten(what_to_glue)
|
||||
what_to_glue = [str(x) for x in what_to_glue]
|
||||
return " ".join(what_to_glue)
|
||||
|
|
7
tests.py
7
tests.py
|
@ -15,7 +15,6 @@ class GlueTests(unittest.TestCase):
|
|||
|
||||
def test_named(self):
|
||||
output = glue(what="bozo", who="clown")
|
||||
print output
|
||||
assert output == "bozo clown"
|
||||
assert "what" not in output
|
||||
|
||||
|
@ -23,5 +22,11 @@ class GlueTests(unittest.TestCase):
|
|||
output = glue("why", ["would", ["you", "run"], "these"], "tests")
|
||||
assert output == "why would you run these tests"
|
||||
|
||||
def test_objects(self):
|
||||
output = glue("why", ["would", ["you", "run"], "these"], "tests", 12345)
|
||||
assert output == "why would you run these tests 12345"
|
||||
output = glue("why", ["would", ["you", "run"], "these"], "tests", False)
|
||||
assert output == "why would you run these tests False"
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue
Block a user