def make_cache(): segs = SegmentList() cache = Cache() for seg in [(0, 1), (1, 2), (4, 5)]: d = seg[1] - seg[0] f = 'A-B-%d-%d.tmp' % (seg[0], d) cache.append(CacheEntry.from_T050017(f)) segs.append(Segment(*seg)) return cache, segs
def make_cache(): segs = SegmentList() cache = Cache() for seg in [(0, 1), (1, 2), (4, 5)]: d = seg[1] - seg[0] _, f = tempfile.mkstemp(prefix='A-', suffix='-%d-%d.tmp' % (seg[0], d)) cache.append(CacheEntry.from_T050017(f)) segs.append(Segment(*seg)) return cache, segs
def test_io_identify(cls, extensions, modes=['read', 'write']): for mode in modes: for ext in extensions: p = 'X-TEST_CACHE_ENTRY-0-1.%s' % ext c = Cache([CacheEntry.from_T050017(p)]) for path in [p, [p], c[0], c]: formats = identify_format(mode, cls, path, None, [], {}) if len(formats) == 0: raise RuntimeError( "No %s.%s method identified for " "file-format %r in form %r" % (cls.__name__, mode, ext, type(path).__name__)) elif len(formats) != 1: raise RuntimeError( "Multiple %s.%s methods identified for " "file-format %r in form %r" % (cls.__name__, mode, ext, type(path).__name__))
def test_io_identify(cls, extensions, modes=['read', 'write']): for mode in modes: for ext in extensions: p = 'X-TEST_CACHE_ENTRY-0-1.%s' % ext c = Cache([CacheEntry.from_T050017(p)]) for path in [p, [p], c[0], c]: formats = identify_format( mode, cls, path, None, [], {}) if len(formats) == 0: raise RuntimeError("No %s.%s method identified for " "file-format %r in form %r" % (cls.__name__, mode, ext, type(path).__name__)) elif len(formats) != 1: raise RuntimeError("Multiple %s.%s methods identified for " "file-format %r in form %r" % (cls.__name__, mode, ext, type(path).__name__))
def test_on_tape(self): self.assertFalse(datafind.on_tape(TEST_GWF_FILE)) self.assertFalse(datafind.on_tape( CacheEntry.from_T050017(TEST_GWF_FILE)))
def test_on_tape(self): self.assertFalse(datafind.on_tape(TEST_GWF_FILE)) self.assertFalse( datafind.on_tape(CacheEntry.from_T050017(TEST_GWF_FILE)))