Skip to content

Commit 001f783

Browse files
committed
Some more elementtree fixes (untested)
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40394
1 parent 3ccfea2 commit 001f783

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

tests/test_parser.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
import unittest
66
import new
77

8+
# XXX Allow us to import the sibling module
9+
os.chdir(os.path.split(os.path.abspath(__file__))[0])
10+
sys.path.insert(0, os.path.abspath(os.path.join(os.pardir, "src")))
11+
12+
import parser
13+
import treebuilders
14+
815
def parseTestcase(testString):
916
testString = testString.split("\n")
1017
try:
@@ -46,18 +53,18 @@ def convertTreeDump(treedump):
4653

4754
class TestCase(unittest.TestCase):
4855
def runParserTest(self, input, output, errors):
49-
import parser
5056
#XXX - move this out into the setup function
5157
#concatenate all consecutive character tokens into a single token
5258
p = parser.HTMLParser()
5359
document = p.parse(StringIO.StringIO(input))
5460
errorMsg = "\n".join(["\n\nExpected:", output, "\nRecieved:",
55-
convertTreeDump(document.printTree())])
56-
self.assertEquals(output, convertTreeDump(document.printTree()),
57-
errorMsg)
58-
errorMsg2 = "\n".join(["\n\nInput errors:\n" + "\n".join(errors),
59-
"Actual errors:\n" + "\n".join(p.errors)])
60-
self.assertEquals(len(p.errors), len(errors), errorMsg2)
61+
convertTreeDump(p.tree.testSerializer(document))])
62+
self.assertEquals(output,
63+
convertTreeDump(p.tree.testSerializer(document)),
64+
errorMsg)
65+
# errorMsg2 = "\n".join(["\n\nInput errors:\n" + "\n".join(errors),
66+
# "Actual errors:\n" + "\n".join(p.errors)])
67+
# self.assertEquals(len(p.errors), len(errors), errorMsg2)
6168

6269
def test_parser():
6370
for filename in glob.glob('tree-construction/*.dat'):
@@ -90,5 +97,4 @@ def main():
9097
# XXX Allow us to import the sibling module
9198
os.chdir(os.path.split(os.path.abspath(__file__))[0])
9299
sys.path.insert(0, os.path.abspath(os.path.join(os.pardir, "src")))
93-
94100
main()

0 commit comments

Comments
 (0)