Пример #1
0
 def test_list_float_or_list_int(self):
     l = [0, 1]
     for lst_like in [l, range(2), tuple(l), array.array('l', l)]:
         converted1 = TypeConverters.to_list_float(lst_like)
         converted2 = TypeConverters.to_list_int(lst_like)
         self.assertEqual(type(converted1), list)
         self.assertEqual(type(converted2), list)
         self.assertListEqual(converted1, l)
         self.assertListEqual(converted2, l)
Пример #2
0
 def test_boolean(self):
     data = True
     converted = TypeConverters.to_boolean(data)
     self.assertEqual(type(converted), bool)
     self.assertEqual(converted, data)
Пример #3
0
 def test_string(self):
     data = "1234567890"
     converted = TypeConverters.to_string(data)
     self.assertEqual(type(converted), str)
     self.assertEqual(converted, data)
Пример #4
0
 def test_int(self):
     data = 1234567890
     converted = TypeConverters.to_int(data)
     self.assertEqual(type(converted), int)
     self.assertEqual(converted, data)
Пример #5
0
 def test_float(self):
     data = 1.45
     converted = TypeConverters.to_float(data)
     self.assertEqual(type(converted), float)
     self.assertEqual(converted, data)
Пример #6
0
 def test_list_string(self):
     l = ["aa", "bb"]
     for lst_like in [l, tuple(l)]:
         converted = TypeConverters.to_list_string(lst_like)
         self.assertEqual(type(converted), list)
         self.assertListEqual(converted, l)
Пример #7
0
 def test_list(self):
     l = [0, 1]
     for lst_like in [l, range(2), tuple(l), array.array('l', l)]:
         converted = TypeConverters.to_list(lst_like)
         self.assertEqual(type(converted), list)
         self.assertListEqual(converted, l)