Revision 351
(checked in by cbc, 14 years ago)
|
Add some functions and tests to parse module.
|
Line | |
---|
1 |
|
---|
2 |
|
---|
3 |
"""Test data for the parse module.""" |
---|
4 |
|
---|
5 |
import os |
---|
6 |
import glob |
---|
7 |
import hashlib |
---|
8 |
|
---|
9 |
PARSE_TEST_PATH = os.path.join("tests","parse") |
---|
10 |
|
---|
11 |
|
---|
12 |
def file_md5(path): |
---|
13 |
"""Return MD5 hash of contents at path.""" |
---|
14 |
|
---|
15 |
hasher = hashlib.md5() |
---|
16 |
hasher.update("".join(open(path).readlines())) |
---|
17 |
return hasher.hexdigest() |
---|
18 |
|
---|
19 |
XML_GLOB = os.path.join(os.path.dirname(os.path.abspath(__file__)), |
---|
20 |
PARSE_TEST_PATH, "xml", "*", "*.xml") |
---|
21 |
XML_PATHS = glob.glob(XML_GLOB) |
---|
22 |
XML_DOC_LENS = dict([(os.path.basename(xml_path), |
---|
23 |
len(open(xml_path).readlines())) |
---|
24 |
for xml_path in XML_PATHS]) |
---|
25 |
XML_DOC_MD5S = dict([(os.path.basename(xml_path), |
---|
26 |
file_md5(xml_path)) |
---|
27 |
for xml_path in XML_PATHS]) |
---|