def test_fast_open(self): with TestAreaContext("index"): f0 = EclFile(self.test_file) f0.write_index("index") f1 = EclFile(self.test_file, 0, "index") for kw0, kw1 in zip(f0, f1): self.assertEqual(kw0, kw1)
def test_fast_open(self): with TestAreaContext("index"): f0 = EclFile( self.test_file ) f0.write_index("index") f1 = EclFile( self.test_file , 0 , "index") for kw0,kw1 in zip(f0,f1): self.assertEqual( kw0,kw1 )
def test_index(self): with TestAreaContext("python/ecl_file/truncated"): f0 = EclFile(self.test_file) f0.write_index("index") f1 = EclFile(self.test_file, index_filename="index") for kw0, kw1 in zip(f0, f1): self.assertEqual(kw0, kw1)
def test_index(self): with TestAreaContext("python/ecl_file/truncated"): f0 = EclFile( self.test_file ) f0.write_index( "index" ) f1 = EclFile( self.test_file , index_filename = "index") for kw0,kw1 in zip(f0,f1): self.assertEqual(kw0,kw1)
def test_ecl_index(self): with TestAreaContext("python/ecl_file/context"): kw1 = EclKW("KW1", 100, EclDataType.ECL_INT) kw2 = EclKW("KW2", 100, EclDataType.ECL_FLOAT) kw3 = EclKW("KW3", 100, EclDataType.ECL_CHAR) kw4 = EclKW("KW4", 100, EclDataType.ECL_STRING(23)) with openFortIO("TEST", mode=FortIO.WRITE_MODE) as f: kw1.fwrite(f) kw2.fwrite(f) kw3.fwrite(f) kw4.fwrite(f) ecl_file = EclFile("TEST") ecl_file.write_index("INDEX_FILE") ecl_file.close() ecl_file_index = EclFile("TEST", 0, "INDEX_FILE") for kw in ["KW1", "KW2", "KW3", "KW4"]: self.assertIn(kw, ecl_file_index) with self.assertRaises(IOError): ecl_file.write_index("does-not-exist/INDEX") with self.assertRaises(IOError): ecl_file_index = EclFile("TEST", 0, "index_does_not_exist") os.mkdir("path") shutil.copyfile("TEST", "path/TEST") ecl_file = EclFile("path/TEST") ecl_file.write_index("path/index") with CWDContext("path"): ecl_file = EclFile("TEST", 0, "index")
def test_ecl_index(self): with TestAreaContext("python/ecl_file/context"): kw1 = EclKW( "KW1" , 100 , EclDataType.ECL_INT) kw2 = EclKW( "KW2" , 100 , EclDataType.ECL_FLOAT) kw3 = EclKW( "KW3" , 100 , EclDataType.ECL_CHAR) kw4 = EclKW( "KW4" , 100 , EclDataType.ECL_STRING(23)) with openFortIO("TEST" , mode = FortIO.WRITE_MODE) as f: kw1.fwrite( f ) kw2.fwrite( f ) kw3.fwrite( f ) kw4.fwrite( f ) ecl_file = EclFile("TEST") ecl_file.write_index("INDEX_FILE") ecl_file.close() ecl_file_index = EclFile("TEST", 0, "INDEX_FILE") for kw in ["KW1","KW2","KW3","KW4"]: self.assertIn( kw , ecl_file_index ) with self.assertRaises(IOError): ecl_file.write_index("does-not-exist/INDEX") os.mkdir("read-only") os.chmod("read-only", 0o444) with self.assertRaises(IOError): ecl_file.write_index("read-only/INDEX") with self.assertRaises(IOError): ecl_file_index = EclFile("TEST", 0, "index_does_not_exist") shutil.copyfile( "INDEX_FILE" , "INDEX_perm_denied") os.chmod("INDEX_perm_denied", 0o000) with self.assertRaises(IOError): ecl_file_index = EclFile("TEST", 0, "INDEX_perm_denied") os.mkdir("path") shutil.copyfile("TEST" , "path/TEST") ecl_file = EclFile("path/TEST") ecl_file.write_index("path/index") with CWDContext("path"): ecl_file = EclFile("TEST" , 0 , "index")