Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import unittest
- def append_to(element, to=[]):
- """
- Append an element to a list.
- If not list provided, create a new list containing only the element.
- :param element: the thing to append
- :param to: the list to append it to
- :return: the list with the appended thing
- """
- to.append(element)
- return to
- class TestAppendTo(unittest.TestCase):
- def test_append_to(self):
- r = append_to('a')
- self.assertListEqual(r, ['a'])
- def test_append_to_two(self):
- r = append_to('b')
- append_to('c', r)
- self.assertListEqual(r, ['b', 'c'])
- unittest.main(exit=False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement