File: test_containers_list.py

package info (click to toggle)
construct 2.10.68%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,812 kB
  • sloc: python: 11,793; makefile: 135
file content (16 lines) | stat: -rw-r--r-- 542 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from tests.declarativeunittest import *
from construct import *
from construct.lib import *


def test_str():
    l = ListContainer(range(5))
    assert str(l) == "ListContainer: \n    0\n    1\n    2\n    3\n    4"
    assert repr(l) == "ListContainer([0, 1, 2, 3, 4])"

    l = ListContainer(range(5))
    print(repr(str(l)))
    print(repr((l)))
    l.append(l)
    assert str(l) == "ListContainer: \n    0\n    1\n    2\n    3\n    4\n    <recursion detected>"
    assert repr(l) == "ListContainer([0, 1, 2, 3, 4, <recursion detected>])"