File: test_unicode_parse.py

package info (click to toggle)
serpent 1.42-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 704 kB
  • sloc: java: 4,025; cs: 3,675; python: 1,734; xml: 149; makefile: 38; sh: 11
file content (28 lines) | stat: -rw-r--r-- 775 bytes parent folder | download | duplicates (4)
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
import os
import io
import re
import serpent
from test_unicode import teststrings


files = [f for f in os.listdir(".") if f.startswith("data_") and f.endswith(".serpent")]

for f in files:
    print("Checking data file", f)
    resultstrings=[]
    with io.open(f, "rb") as inf:
        data = inf.read()
        data = re.split(b"~\n~\n", data)[:-1]
        assert len(data) == len(teststrings)
        # data = data[:-2] # XXX
        for num, d in enumerate(data, start=1):
            try:
                print("data item ",num,"...")
                resultstrings.append(serpent.loads(d))
            except Exception as x:
                print("\nSERPENT ERROR", type(x))

    if resultstrings==teststrings:
        print("OK")
    else:
        print("!!!FAIL!!!")