1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
import os
from eccodes import GribFile
from eccodes import codes_samples_path
def test_iterating_through_grib_file():
sample_path = os.path.join(codes_samples_path(), "GRIB2.tmpl")
with GribFile(sample_path) as grib:
count = 0
for msg in grib:
count += 1
assert count == 1
def test_iterating_through_grib_file_manual_close():
sample_path = os.path.join(codes_samples_path(), "GRIB2.tmpl")
with GribFile(sample_path) as grib:
count = 0
for msg in grib:
count += 1
msg.close()
assert count == 1
|