def test_parse_and_filter_file_prefix_and_postfix_specified(self): ''' DUMPER ''' path = make_temp_file(self.tmp_dir, 'x\n') parsed_file = parse_and_filter_file(path, prefix=path + 'X', postfix='Y', cache_dir=self.tmp_dir) eq_(parsed_file, path + 'X_Y') os.unlink(path) os.unlink(parsed_file)
def test_parse_and_filter_file_default_naming(self): ''' DUMPER ''' path = make_temp_file(self.tmp_dir, 'x\n') parsed_file = parse_and_filter_file(path, cache_dir=self.tmp_dir) eq_(parsed_file, os.path.join(self.tmp_dir, os.path.basename(path) + '_parsed')) os.unlink(path) os.unlink(parsed_file)
def test_parse_and_filter_file_parser_function(self): ''' DUMPER ''' fake_data = 'asd\nasda\n' path = make_temp_file(self.tmp_dir, fake_data) parsed_file = parse_and_filter_file(path, parser=str.strip, cache_dir=self.tmp_dir) with open(parsed_file) as f: data = f.read() eq_(fake_data, data) os.unlink(path) os.unlink(parsed_file)
def test_parse_and_filter_file_prefix_specified(self): ''' DUMPER ''' path = make_temp_file(self.tmp_dir, 'x\n') parsed_file = parse_and_filter_file(path, prefix=path + 'X', cache_dir=self.tmp_dir) assert parsed_file == path + 'X_parsed' os.unlink(path) os.unlink(parsed_file)
def test_parse_and_filter_file_filter_function(self): ''' DUMPER ''' fake_data = 'asd\nasda\n' path = make_temp_file(self.tmp_dir, fake_data) parsed_file = parse_and_filter_file(path, filter_=lambda s: s == 'asd\n', cache_dir=self.tmp_dir) with open(parsed_file) as f: data = f.read() eq_('asd\n\n', data) os.unlink(path) os.unlink(parsed_file)
def test_parse_and_filter_file_default_parameters(self): ''' DUMPER ''' fake_data = 'asd\nasda\n' path = make_temp_file(self.tmp_dir, fake_data) parsed_file = parse_and_filter_file(path, cache_dir=self.tmp_dir) with open(parsed_file) as f: data = f.read() eq_(fake_data.replace('\n', '\n\n'), data) os.unlink(path) os.unlink(parsed_file)