File: test_suite.py

package info (click to toggle)
mf2py 2.0.1-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 664 kB
  • sloc: python: 1,917; makefile: 19
file content (28 lines) | stat: -rw-r--r-- 731 bytes parent folder | download
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 glob
import json
import os.path
import sys

from test_parser import check_unicode

import mf2py


def test_mf2tests():
    allfiles = glob.glob(os.path.join(".", "testsuite", "tests", "*", "*", "*.json"))
    for jsonfile in allfiles:
        htmlfile = jsonfile[:-4] + "html"
        with open(htmlfile) as f:
            p = mf2py.parse(doc=f, url="http://example.com")
            check_unicode(htmlfile, p)
        with open(jsonfile) as jsonf:
            try:
                s = json.load(jsonf)
            except:
                s = "bad file: " + jsonfile + sys.exc_info()[0]
        check_mf2(htmlfile, p, s)


def check_mf2(htmlfile, p, s):
    # TODO ignore extra keys in p that are not in s
    assert p == s