def test_simple_split(self): self.assertEqual(list(cast.my_split('1,2,3,4')), ['1','2','3','4']) self.assertEqual(list(cast.my_split('1,"2,3",4')), ['1','"2,3"','4']) self.assertEqual(list(cast.my_split("1,'2,3',4")), ['1',"'2,3'",'4'])
def test_complex_split(self): long_str = 'PROGRAM-ID=1,BANDWIDTH=602230,CODECS="avc1.66.31, mp4a.40.2",RESOLUTION=320x240' exp_res = [ 'PROGRAM-ID=1', 'BANDWIDTH=602230', 'CODECS="avc1.66.31, mp4a.40.2"', 'RESOLUTION=320x240' ] self.assertEqual(list(cast.my_split(long_str)), exp_res)
def test_single_item(self): self.assertEqual(list(cast.my_split('test')), ['test'])
def test_trailing_comma(self): self.assertEqual(list(cast.my_split('1,2,3,')), ['1', '2', '3'])
def test_trailing_comma(self): self.assertEqual(list(cast.my_split('1,2,3,')), ['1','2','3'])
def test_complex_split(self): long_str = 'PROGRAM-ID=1,BANDWIDTH=602230,CODECS="avc1.66.31, mp4a.40.2",RESOLUTION=320x240' exp_res = ['PROGRAM-ID=1','BANDWIDTH=602230', 'CODECS="avc1.66.31, mp4a.40.2"','RESOLUTION=320x240'] self.assertEqual(list(cast.my_split(long_str)),exp_res)