File: test_slice_objs.py

package info (click to toggle)
extra-data 1.20.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 952 kB
  • sloc: python: 10,421; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 511 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from extra_data import by_id, by_index


def test_slicing_reprs():
    ns = {'by_id': by_id, 'by_index': by_index}

    samples = [
        'by_id[:]',
        'by_id[:2]',
        'by_id[0:10:2]',
        'by_id[4::2, 7]',
        'by_index[:5, 3:12]',
        'by_index[-4:, ...]',
        'by_index[...]',
        'by_index[..., ::-1]',
    ]

    # These examples are canonically formatted, so their repr() should match
    for expr in samples:
        obj = eval(expr, ns)
        assert repr(obj) == expr