File: test_high_level_api.py

package info (click to toggle)
eccodes-python 2%3A1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 400 kB
  • sloc: python: 2,695; ansic: 262; makefile: 83
file content (22 lines) | stat: -rw-r--r-- 585 bytes parent folder | download
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