예제 #1
0
 def test_no_scalar(self):
     self.assertEqual(iterutils.listify(['foo'], scalar_ok=False), ['foo'])
     self.assertEqual(
         iterutils.listify(['foo'], always_copy=True, scalar_ok=False),
         ['foo'])
     self.assertRaises(TypeError, iterutils.listify, 1, scalar_ok=False)
     self.assertRaises(TypeError, iterutils.listify, 'foo', scalar_ok=False)
예제 #2
0
    def test_type(self):
        x = 'foo'
        res = iterutils.listify(x, type=tuple)
        self.assertEqual(res, ('foo', ))

        y = ['foo', 'bar']
        res = iterutils.listify(y, type=tuple)
        self.assertEqual(res, ('foo', 'bar'))
예제 #3
0
 def test_always_copy(self):
     x = ['foo', 'bar']
     res = iterutils.listify(x, always_copy=True)
     self.assertEqual(res, x)
     self.assertTrue(x is not res)
예제 #4
0
 def test_many(self):
     x = ['foo', 'bar']
     res = iterutils.listify(x)
     self.assertEqual(res, x)
     self.assertTrue(x is res)
예제 #5
0
 def test_one(self):
     self.assertEqual(iterutils.listify('foo'), ['foo'])
예제 #6
0
 def test_none(self):
     self.assertEqual(iterutils.listify(None), [])