2014-10-30 18:07:41 +00:00
|
|
|
import unittest
|
|
|
|
from glue import glue
|
|
|
|
|
|
|
|
|
|
|
|
class GlueTests(unittest.TestCase):
|
|
|
|
|
|
|
|
def test_tuple(self):
|
|
|
|
output = glue("why", "would", "you", "run", "these", "tests")
|
|
|
|
assert output == "why would you run these tests"
|
|
|
|
|
2017-01-23 15:27:56 +00:00
|
|
|
def test_tuple_custom_separator(self):
|
|
|
|
output = glue("why", "would", "you", separator=",")
|
|
|
|
assert output == "why,would,you"
|
|
|
|
|
2014-10-30 18:07:41 +00:00
|
|
|
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"
|
2014-10-30 18:08:51 +00:00
|
|
|
assert "who" not in output
|
2014-10-30 18:07:41 +00:00
|
|
|
|
|
|
|
def test_named(self):
|
|
|
|
output = glue(what="bozo", who="clown")
|
|
|
|
assert output == "bozo clown"
|
2014-10-30 18:08:51 +00:00
|
|
|
assert "what" not in output
|
2014-10-30 18:07:41 +00:00
|
|
|
|
2014-10-30 18:27:36 +00:00
|
|
|
def test_flaten(self):
|
|
|
|
output = glue("why", ["would", ["you", "run"], "these"], "tests")
|
|
|
|
assert output == "why would you run these tests"
|
|
|
|
|
2014-10-30 18:30:22 +00:00
|
|
|
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"
|
|
|
|
|
2014-10-30 18:07:41 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|