def test_is_sacxy_open_file_binary_mode(self): """ Tests the _is_sac_xy function for open files in binary mode. """ with open(self.filexy, "rb") as fh: self.assertTrue(_is_sac_xy(fh)) with open(__file__, "rb") as fh: self.assertFalse(_is_sac_xy(fh))
def test_is_sacxy_bytes_io(self): """ Tests the _is_sac_xy 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_sac_xy(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_sac_xy(buf))