File: test_parser.py

package info (click to toggle)
pycson 0.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 284 kB
  • sloc: python: 546; makefile: 3
file content (20 lines) | stat: -rw-r--r-- 631 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import cson, os, json

def test_parser():
    srcdir = os.path.join(os.path.split(__file__)[0], 'parser')
    for name in os.listdir(srcdir):
        if not name.endswith('.cson'):
            continue

        cson_fname = os.path.join(srcdir, name)
        with open(cson_fname, 'rb') as fin:
            c = cson.load(fin)

        json_name = name[:-5] + '.json'
        with open(os.path.join(srcdir, json_name), 'rb') as fin:
            j = json.loads(fin.read().decode('utf-8'))

        assert c == j
        with open(os.path.join(srcdir, json_name), 'rb') as fin:
            c = cson.load(fin)
        assert c == j