Re: [xml] Missing line numbers in error handling



While trying to expand the python/tests/tstLastError.py code to test validation and not just well-formedness, I'm finding a memory leak from the debugMemory call in tearDown. Specifically, adding the following test:

    def test3(self):
        """Test a validation error: we get the last error only"""
        s = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
<head>
    <title><!-- Insert your title here --></title>
</head>
<bodyBROKEN>
</bodyBROKEN>
</html>"""
        self.failUnlessXmlError(libxml2.readMemory,
                        (s,len(s),"dummy.xml",None,0),
libxml2.treeError, # not sure what it should be yet
                        domain=libxml2.XML_FROM_PARSER,
                        code=libxml2.XML_ERR_TAG_NOT_FINISHED,
                        message='Premature end of data in tag x line 1\n',
                        level=libxml2.XML_ERR_FATAL,
                        file='dummy.xml',
                        line=3)


while I'm not expecting the test to run yet (as I haven't tweaked the expected exception yet), but I'm not expecting (note that the "FE" is printed by libxml (!?):

C:\foo>python tstLastError.py
..FE
======================================================================
ERROR: Test a validation error: we get the last error only
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tstLastError.py", line 15, in tearDown
    self.fail("Memory leak %d bytes" % (libxml2.debugMemory(1),))
  File "C:\Python23\lib\unittest.py", line 270, in fail
    raise self.failureException, msg
AssertionError: Memory leak 4415 bytes

======================================================================
FAIL: Test a validation error: we get the last error only
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tstLastError.py", line 90, in test3
    line=3)
  File "tstLastError.py", line 44, in failUnlessXmlError
    self.fail("exception %s should have been raised" % exc)
  File "C:\Python23\lib\unittest.py", line 270, in fail
    raise self.failureException, msg
AssertionError: exception libxml2.treeError should have been raised

----------------------------------------------------------------------

1) Can others replicate? (it's running against the latest windows binary distribution, while the test is from the latest CVS snapshot, if that makes a difference).

2) Suggestions for what to fix?

--david



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]