def test_field_guess_filetype(self): with TestAreaContext('field_config') as test_context: fname = abspath('test.kw.grdecl') print(fname) with open(fname, 'w') as f: f.write("-- my comment\n") f.write("-- more comments\n") f.write("SOWCR\n") for i in range(256//8): # technicalities demand file has >= 256B f.write("0 0 0 0\n") ft = FieldConfig.guessFiletype(fname) grdecl_type = EnkfFieldFileFormatEnum(5) self.assertEqual('ECL_GRDECL_FILE', grdecl_type.name) self.assertEqual(grdecl_type, ft)
def test_field_guess_filetype(self): with TestAreaContext("field_config") as test_context: fname = abspath("test.kw.grdecl") with open(fname, "w") as f: f.write("-- my comment\n") f.write("-- more comments\n") f.write("SOWCR\n") # The function guessing file types determines whether the file # is binary or 7 bit ASCII based on bit 8 heuristics. For this # to be "reliable" the file is required to be more than 256 # bytes. for i in range(256 // 8): f.write("0 0 0 0\n") ft = FieldConfig.guessFiletype(fname) grdecl_type = EnkfFieldFileFormatEnum(5) self.assertEqual("ECL_GRDECL_FILE", grdecl_type.name) self.assertEqual(grdecl_type, ft)