Skip to content

Commit

Permalink
Add test-case that motivates the broken scenario for the existing fla…
Browse files Browse the repository at this point in the history
…tten

It fails when it's nested several levels.  Also fix a unit test broken
by the current change that relied on only list being flattened by
default
  • Loading branch information
Vitali Lovich committed May 22, 2015
1 parent 9c37029 commit 71aabca
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion master/buildbot/test/unit/test_util.py
Expand Up @@ -236,9 +236,19 @@ def test_deep(self):
self.assertEqual(util.flatten([[1, 2], 3, [[4]]]),
[1, 2, 3, 4])

def test_deeply_nested(self):
self.assertEqual(util.flatten([5, [6, (7, 8)]]),
[5, 6, 7, 8])

def test_tuples(self):
self.assertEqual(util.flatten([(1, 2), 3]), [(1, 2), 3])
self.assertEqual(util.flatten([(1, 2), 3]), [1, 2, 3])

def test_dict(self):
d = {'a': [5, 6, 7], 'b': [7, 8, 9]}
self.assertEqual(util.flatten(d), d)

def test_string(self):
self.assertEqual(util.flatten("abc"), "abc")

class Ascii2Unicode(unittest.TestCase):

Expand Down

0 comments on commit 71aabca

Please sign in to comment.