Exemple #1
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))
Exemple #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))
Exemple #3
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))
Exemple #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))