def load_test_archive(test_file, offset, length): path = utils.test_data_dir() + 'warcs/' + test_file archive = testloader.load(path, offset, length) pprint.pprint((archive.type, archive.rec_headers, archive.status_headers))
self[header] = field self.cdxline = cdxline def __setitem__(self, key, value): OrderedDict.__setitem__(self, key, value) # force regen on next __str__ call self.cdxline = None def __str__(self): if self.cdxline: return self.cdxline li = itertools.imap(lambda (n, val): val, self.items()) return ' '.join(li) # Testing import utils if __name__ == "__main__" or utils.enable_doctests(): from pprint import pprint test_dir = utils.test_data_dir() + 'cdx/' import doctest doctest.testmod()
def create_test_cdx(test_file): path = utils.test_data_dir() + 'cdx/' + test_file return FileReader(path)