Example #1
0
 def test_multiple_types(self):
     self.assertEquals(
         list(flatten(['a', ('b', 'c')])),
         ['a', 'b', 'c'])
Example #2
0
 def test_flattens(self):
     self.assertEquals(
         list(flatten([1, [2, 3]])), 
         [1, 2, 3])
Example #3
0
 def test_can_flatten_strings_if_asked(self):
     self.assertEquals(
         list(flatten('abc', excluded_types=())),
         ['a', 'b', 'c'])
Example #4
0
 def test_sets(self):
     self.assertEquals(
         list(flatten(set(['a', 'bc']))),
         ['a', 'bc'])
Example #5
0
 def test_flattens(self):
     self.assertEquals(list(flatten([1, [2, 3]])), [1, 2, 3])
Example #6
0
 def test_flattens_strings(self):
     self.assertEquals(
         list(flatten(
             [['one', 'two'], 'three', ['four', ['five', 'six']]])),
         ['one', 'two', 'three', 'four', 'five', 'six'])
Example #7
0
 def test_multiple_types(self):
     self.assertEquals(list(flatten(['a', ('b', 'c')])), ['a', 'b', 'c'])
Example #8
0
 def test_sets(self):
     self.assertEquals(list(flatten(set(['a', 'bc']))), ['a', 'bc'])
Example #9
0
 def test_can_flatten_strings_if_asked(self):
     self.assertEquals(list(flatten('abc', excluded_types=())),
                       ['a', 'b', 'c'])
Example #10
0
 def test_flattens_strings(self):
     self.assertEquals(
         list(flatten([['one', 'two'], 'three', ['four', ['five',
                                                          'six']]])),
         ['one', 'two', 'three', 'four', 'five', 'six'])
Example #11
0
    def test_singleton(self):
        self.assertEquals(list(flatten('abc')), ['abc'])

        self.assertEquals(list(flatten(1)), [1])

        self.assertEquals(list(flatten(None)), [])