-
Notifications
You must be signed in to change notification settings - Fork 530
/
test_print.py
46 lines (34 loc) · 1.48 KB
/
test_print.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from future.builtins import * # NOQA
import os
import unittest
from obspy.scripts.print import main as obspy_print
from obspy.core.util.misc import CatchOutput
class PrintTestCase(unittest.TestCase):
def setUp(self):
self.all_files = [os.path.join(os.path.dirname(__file__), os.pardir,
os.pardir, 'io', 'ascii', 'tests',
'data', x)
for x in ['slist.ascii', 'tspair.ascii']]
def test_print(self):
with CatchOutput() as out:
obspy_print(self.all_files)
expected = '''1 Trace(s) in Stream:
XX.TEST..BHZ | 2008-01-15T00:00:00.025000Z - 2008-01-15T00:00:15.875000Z | 40.0 Hz, 635 samples
''' # noqa
self.assertEqual(expected, out.stdout)
def test_print_nomerge(self):
with CatchOutput() as out:
obspy_print(['--no-merge'] + self.all_files)
expected = '''2 Trace(s) in Stream:
XX.TEST..BHZ | 2008-01-15T00:00:00.025000Z - 2008-01-15T00:00:15.875000Z | 40.0 Hz, 635 samples
XX.TEST..BHZ | 2008-01-15T00:00:00.025000Z - 2008-01-15T00:00:15.875000Z | 40.0 Hz, 635 samples
''' # noqa
self.assertEqual(expected, out.stdout)
def suite():
return unittest.makeSuite(PrintTestCase, 'test')
if __name__ == '__main__':
unittest.main(defaultTest='suite')