File: test_count.py

package info (click to toggle)
pyodc 1.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 700 kB
  • sloc: python: 2,369; ansic: 86; makefile: 32
file content (45 lines) | stat: -rw-r--r-- 1,195 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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import os

import pytest
from conftest import odc_modules

data_file1 = os.path.join(os.path.dirname(__file__), "data/data1.odb")


@pytest.mark.parametrize("odyssey", odc_modules)
def test_count(odyssey):
    r = odyssey.Reader(data_file1, aggregated=False)

    frames = r.frames

    assert len(frames) == 11
    assert all(t.ncolumns == 55 for t in frames)
    assert sum(t.nrows for t in frames) == 13


@pytest.mark.parametrize("odyssey", odc_modules)
def test_count_file(odyssey):
    """Check that we can open a file like object"""
    with open(data_file1, "rb") as f:
        r = odyssey.Reader(f, aggregated=False)

    frames = r.frames
    assert len(frames) == 11
    assert all(t.ncolumns == 55 for t in frames)
    assert sum(t.nrows for t in frames) == 13


@pytest.mark.parametrize("odyssey", odc_modules)
def test_count_aggregated_file(odyssey):
    """Check that we can open a file like object"""
    with open(data_file1, "rb") as f:
        r = odyssey.Reader(f, aggregated=True)

    frames = r.frames
    assert len(frames) == 1
    assert all(t.ncolumns == 55 for t in frames)
    assert sum(t.nrows for t in frames) == 13


if __name__ == "__main__":
    pytest.main()