Ejemplo n.º 1
0
def test_logical_file_populate_frame_array_partial_split():
    fobj = io.BytesIO(test_data.BASIC_FILE)
    with LogicalFile.LogicalIndex(fobj) as logical_index:
        assert len(logical_index) == 1
        logical_file = logical_index.logical_files[0]
        assert logical_file.has_log_pass
        assert len(logical_file.log_pass) == 1
        frame_array = logical_file.log_pass[0]
        frame_slice = Slice.Sample(64)
        frame_count = logical_file.populate_frame_array(
            frame_array, frame_slice)
        assert frame_count == 64
Ejemplo n.º 2
0
def test_sample_12(init, expected):
    s = Slice.Sample(init)
    result = list(s.gen_indices(12))
    assert len(result) == min(init, 12)
    assert result == expected
Ejemplo n.º 3
0
def test_sample_long_str(init, length, expected):
    s = Slice.Sample(init)
    assert s.long_str(length) == expected
Ejemplo n.º 4
0
def test_sample_str(init, expected):
    s = Slice.Sample(init)
    assert str(s) == expected
Ejemplo n.º 5
0
def test_sample_eq():
    assert Slice.Sample(7) == Slice.Sample(7)
    assert Slice.Sample(7) != 1
Ejemplo n.º 6
0
def test_sample_indices(init, length, expected):
    s = Slice.Sample(init)
    assert s.indices(length) == expected
Ejemplo n.º 7
0
def test_sample_range_enumerate(init, length, expected):
    s = Slice.Sample(init)
    result = list(enumerate(s.gen_indices(length)))
    assert result == expected
Ejemplo n.º 8
0
def test_sample_range(init, length, expected):
    s = Slice.Sample(init)
    assert list(s.gen_indices(length)) == expected
Ejemplo n.º 9
0
def test_sample_count(init, length, expected):
    s = Slice.Sample(init)
    assert s.count(length) == expected
Ejemplo n.º 10
0
def test_sample_step(init, length, expected):
    s = Slice.Sample(init)
    assert s.step(length) == expected
Ejemplo n.º 11
0
def test_sample_ctor_raises(init, error_message):
    with pytest.raises(ValueError) as err:
        Slice.Sample(init)
    assert err.value.args[0] == error_message
Ejemplo n.º 12
0
    (
        # Slice
        (',,', Slice.Slice()),
        ('None,None,None', Slice.Slice()),
        ('None,None,None  ', Slice.Slice()),
        ('  None,None,None', Slice.Slice()),
        ('None , None , None', Slice.Slice()),
        ('None,1,None', Slice.Slice(stop=1)),
        ('1,10,None', Slice.Slice(1, 10)),
        ('1,10,2', Slice.Slice(1, 10, 2)),
        # ('', Slice.Slice(None, None, None)),
        # (',', Slice.Slice(None, None, None)),
        # (',1', Slice.Slice(None, 1, None)),
        # ('1,', Slice.Slice(1, None, None)),
        # Sample
        ('1', Slice.Sample(1)),
        ('64', Slice.Sample(64)),
    ))
def test_create_slice_or_sample(init, expected):
    s = Slice.create_slice_or_sample(init)
    assert s == expected


@pytest.mark.parametrize(
    'init, expected',
    (
        # Slice
        (',,,', 'Wrong number of parts for a Slice in ",,,"'),
        ('Z,,,', "invalid literal for int() with base 10: 'Z'"),
        # Sample
        ('-1', 'A Sample must be an integer >= 1 not -1'),