blob: ec0250a507f8cd453a0d05fccd5ea12ebddb0b7e (
plain)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#!/usr/bin/env python3
# -*- encoding: UTF-8 -*-
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
import sys
sys.path.append(sys.path[0] + "/../..")
wmf_dumper = __import__('wmf-dump')
from xml.etree import ElementTree
import unittest
import os
class Test(unittest.TestCase):
def dump(self, name):
try:
os.unlink("%s.wmf.xml" % name)
except OSError:
pass
sock = open("%s.wmf.xml" % name, "w")
saved = sys.stdout
sys.stdout = sock
dumper = wmf_dumper.WMFDumper("%s.wmf" % name)
dumper.dump()
sys.stdout = saved
sock.close()
tree = ElementTree.parse('%s.wmf.xml' % name)
self.root = tree.getroot()
# Make sure everything is dumped - so it can't happen that dump(a) == dump(b), but a != b.
self.assertEqual(0, len(self.root.findall('todo')))
def test_pass(self):
"""This test just makes sure that all files in the 'pass' directory are
dumped without problems."""
for dirname, dirnames, filenames in os.walk('pass'):
for filename in filenames:
if filename.endswith(".wmf"):
self.dump(os.path.join(dirname, filename).replace('.wmf', ''))
if __name__ == '__main__':
unittest.main()
# vim:set filetype=python shiftwidth=4 softtabstop=4 expandtab:
|