コード例 #1
0
ファイル: test_core.py プロジェクト: jshridha/obspy
    def test_is_sacxy_open_file_binary_mode(self):
        """
        Tests the _is_sacXY function for open files in binary mode.
        """
        with open(self.filexy, "rb") as fh:
            self.assertTrue(_is_sacXY(fh))

        with open(__file__, "rb") as fh:
            self.assertFalse(_is_sacXY(fh))
コード例 #2
0
    def test_is_sacxy_open_file_binary_mode(self):
        """
        Tests the _is_sacXY function for open files in binary mode.
        """
        with open(self.filexy, "rb") as fh:
            self.assertTrue(_is_sacXY(fh))

        with open(__file__, "rb") as fh:
            self.assertFalse(_is_sacXY(fh))
コード例 #3
0
ファイル: test_core.py プロジェクト: jshridha/obspy
    def test_is_sacxy_bytes_io(self):
        """
        Tests the _is_sacXY function for BytesIO objects.
        """
        with io.BytesIO() as buf:
            # Read file to BytesIO.
            with open(self.filexy, "rb") as fh:
                buf.write(fh.read())
            buf.seek(0, 0)
            self.assertTrue(_is_sacXY(buf))

        # Should naturally fail for a normal sac file.
        with io.BytesIO() as buf:
            # Read file to BytesIO.
            with open(self.file, "rb") as fh:
                buf.write(fh.read())
            buf.seek(0, 0)
            self.assertFalse(_is_sacXY(buf))
コード例 #4
0
    def test_is_sacxy_bytes_io(self):
        """
        Tests the _is_sacXY function for BytesIO objects.
        """
        with io.BytesIO() as buf:
            # Read file to BytesIO.
            with open(self.filexy, "rb") as fh:
                buf.write(fh.read())
            buf.seek(0, 0)
            self.assertTrue(_is_sacXY(buf))

        # Should naturally fail for a normal sac file.
        with io.BytesIO() as buf:
            # Read file to BytesIO.
            with open(self.file, "rb") as fh:
                buf.write(fh.read())
            buf.seek(0, 0)
            self.assertFalse(_is_sacXY(buf))