예제 #1
0
    def test_single_field(self):
        value = 'some_file.json.00000'
        delimiter = '.'

        self.assertEqual('some_file', pycut.cut(value, '1', delimiter))
        self.assertEqual('json', pycut.cut(value, '2', delimiter))
        self.assertEqual('00000', pycut.cut(value, '3', delimiter))
예제 #2
0
    def test_field_segments(self):
        value = 'some_file.ini.json.00000'
        delimiter = '.'

        self.assertEqual('some_file.ini', pycut.cut(value, '1,2', delimiter))
        self.assertEqual('some_file.json', pycut.cut(value, '1,3', delimiter))
        self.assertEqual('some_file.ini.00000',
                         pycut.cut(value, '1:2,4', delimiter))
예제 #3
0
    def test_field_range(self):
        value = 'some_file.json.00000'
        delimiter = '.'

        self.assertEqual('some_file.json', pycut.cut(value, '1:2', delimiter))
        self.assertEqual('json.00000', pycut.cut(value, '2:3', delimiter))
        self.assertEqual('some_file.json.00000',
                         pycut.cut(value, '1:3', delimiter))
예제 #4
0
    def test_field_segments_negative(self):
        value = 'some_file.ini.json.00000'
        delimiter = '.'

        self.assertEqual('some_file.ini.json',
                         pycut.cut(value, '1:2,-1', delimiter))
예제 #5
0
    def test_open_field_range_negative(self):
        value = 'some_file.ini.json.00000'
        delimiter = '.'

        self.assertEqual('some_file.ini', pycut.cut(value, ':-2', delimiter))