Пример #1
0
    def _test_frame_read_format(self, format):
        # test with specific format
        try:
            self.frame_read(format=format)
        except ImportError as e:
            self.skipTest(str(e))
        else:
            # test again with no format argument
            # but we need to move other readers out of the way first
            try:
                read_ = get_reader('gwf', TimeSeries)
            except Exception:
                pass
            else:
                register_reader('gwf',
                                TimeSeries,
                                get_reader(format, TimeSeries),
                                force=True)
                try:
                    self.frame_read()
                finally:
                    register_reader('gwf', TimeSeries, read_, force=True)
            # test empty Cache()
            self.assertRaises(ValueError,
                              self.TEST_CLASS.read,
                              Cache(),
                              self.channel,
                              format=format)

            # test cache method with `nproc=2`
            c = Cache.from_urls([TEST_GWF_FILE])
            ts = self.TEST_CLASS.read(c, self.channel, nproc=2, format=format)
Пример #2
0
 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
Пример #3
0
 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
Пример #4
0
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__))