def test_4c(self): """Read string""" ffile = os.path.join(self.tdir, 'fort.4') fb = FortranBinary(ffile) with self.assertRaises(ValueError): rec = fb.find(1.0) fb.close()
def test_4b(self): """Read string""" ffile = os.path.join(self.tdir, 'fort.4') fb = FortranBinary(ffile) rec = fb.find(b'ABC') self.assertIn(b'ABC', rec) fb.close()
def test_2b(self): """Handle label not found character*5 lab integer n lab = 'LABEL' n = 0 open(1, file='fort.2', status='new', form='unformatted') write(1) n write(1) lab close(1) end """ ffile = os.path.join(self.tdir, 'fort.2') fb = FortranBinary(ffile) rec = fb.find(b'NOLABEL') fb.close() self.assertEqual(rec, None)
def test_2(self): """Find and read label character*5 lab integer n lab = 'LABEL' n = 0 open(1, file='fort.2', status='new', form='unformatted') write(1) n write(1) lab close(1) end """ ffile = os.path.join(self.tdir, 'fort.2') fb = FortranBinary(ffile) rec = fb.find(b'LABEL') self.assertEqual(rec.data, b'LABEL') fb.close()