Пример #1
0
    def test_read_xy_write_xy_from_open_file_binary_mode(self):
        """
        Reading/writing XY sac files to open files in binary mode.
        """
        # Original.
        st = _read_sac_xy(self.filexy)

        with NamedTemporaryFile() as tf:
            _write_sac_xy(st, tf)
            tf.seek(0, 0)
            st2 = _read_sac_xy(tf)

        self.assertEqual(st, st2)
Пример #2
0
    def test_read_xy_write_xy_from_bytes_io(self):
        """
        Reading/writing XY sac files from/to io.BytesIO. It's alphanumeric
        so bytes should also do the trick.
        """
        # Original.
        st = _read_sac_xy(self.filexy)

        with io.BytesIO() as fh:
            _write_sac_xy(st, fh)
            fh.seek(0, 0)
            st2 = _read_sac_xy(fh)

        self.assertEqual(st, st2)
Пример #3
0
    def test_read_xy_write_xy_from_open_file_binary_mode(self):
        """
        Reading/writing XY sac files to open files in binary mode.
        """
        # Original.
        st = _read_sac_xy(self.filexy)

        with NamedTemporaryFile() as tf:
            _write_sac_xy(st, tf)
            tf.seek(0, 0)
            st2 = _read_sac_xy(tf)

        st[0].stats.pop('sac', None)
        st2[0].stats.pop('sac', None)

        self.assertEqual(st, st2)
Пример #4
0
    def test_read_xy_write_xy_from_bytes_io(self):
        """
        Reading/writing XY sac files from/to io.BytesIO. It's alphanumeric
        so bytes should also do the trick.
        """
        # Original.
        st = _read_sac_xy(self.filexy)

        with io.BytesIO() as fh:
            _write_sac_xy(st, fh)
            fh.seek(0, 0)
            st2 = _read_sac_xy(fh)

        st[0].stats.pop('sac', None)
        st2[0].stats.pop('sac', None)

        self.assertEqual(st, st2)
Пример #5
0
    def test_read_xy_write_xy_from_open_file_binary_mode(self):
        """
        Reading/writing XY sac files to open files in binary mode.
        """
        # Original.
        st = _read_sac_xy(self.filexy)

        with NamedTemporaryFile() as tf:
            with warnings.catch_warnings(record=True) as w:
                warnings.simplefilter('always')
                _write_sac_xy(st, tf)
                self.assertEqual(len(w), 1)
                self.assertIn('reftime', str(w[-1].message))
            tf.seek(0, 0)
            st2 = _read_sac_xy(tf)

        self.assertEqual(st, st2)
Пример #6
0
    def test_read_xy_write_xy_from_open_file_binary_mode(self):
        """
        Reading/writing XY sac files to open files in binary mode.
        """
        # Original.
        st = _read_sac_xy(self.filexy)

        with NamedTemporaryFile() as tf:
            with warnings.catch_warnings(record=True) as w:
                warnings.simplefilter('always')
                _write_sac_xy(st, tf)
                self.assertEqual(len(w), 1)
                self.assertIn('reftime', str(w[-1].message))
            tf.seek(0, 0)
            st2 = _read_sac_xy(tf)

        self.assertEqual(st, st2)
Пример #7
0
    def test_read_xy_write_xy_from_bytes_io(self):
        """
        Reading/writing XY sac files from/to io.BytesIO. It's alphanumeric
        so bytes should also do the trick.
        """
        # Original.
        st = _read_sac_xy(self.filexy)

        with io.BytesIO() as fh:
            with warnings.catch_warnings(record=True) as w:
                warnings.simplefilter('always')
                _write_sac_xy(st, fh)
                self.assertEqual(len(w), 1)
                self.assertIn('reftime', str(w[-1].message))
            fh.seek(0, 0)
            st2 = _read_sac_xy(fh)

        self.assertEqual(st, st2)
Пример #8
0
    def test_read_xy_write_xy_from_bytes_io(self):
        """
        Reading/writing XY sac files from/to io.BytesIO. It's alphanumeric
        so bytes should also do the trick.
        """
        # Original.
        st = _read_sac_xy(self.filexy)

        with io.BytesIO() as fh:
            with warnings.catch_warnings(record=True) as w:
                warnings.simplefilter('always')
                _write_sac_xy(st, fh)
                self.assertEqual(len(w), 1)
                self.assertIn('reftime', str(w[-1].message))
            fh.seek(0, 0)
            st2 = _read_sac_xy(fh)

        self.assertEqual(st, st2)