[Lxml-checkins] r48177 - in lxml/branch/lxml-1.3: . src/lxml/tests
scoder at codespeak.net
scoder at codespeak.net
Mon Oct 29 20:50:16 CET 2007
Author: scoder
Date: Mon Oct 29 20:50:15 2007
New Revision: 48177
Modified:
lxml/branch/lxml-1.3/CHANGES.txt
lxml/branch/lxml-1.3/src/lxml/tests/common_imports.py
lxml/branch/lxml-1.3/src/lxml/tests/test_classlookup.py
lxml/branch/lxml-1.3/src/lxml/tests/test_elementtree.py
lxml/branch/lxml-1.3/src/lxml/tests/test_htmlparser.py
lxml/branch/lxml-1.3/src/lxml/tests/test_io.py
lxml/branch/lxml-1.3/src/lxml/tests/test_nsclasses.py
lxml/branch/lxml-1.3/src/lxml/tests/test_objectify.py
lxml/branch/lxml-1.3/src/lxml/tests/test_pyclasslookup.py
Log:
run gc.collect() after each test to make sure we catch GC bugs
Modified: lxml/branch/lxml-1.3/CHANGES.txt
==============================================================================
--- lxml/branch/lxml-1.3/CHANGES.txt (original)
+++ lxml/branch/lxml-1.3/CHANGES.txt Mon Oct 29 20:50:15 2007
@@ -15,6 +15,14 @@
* Well hidden free-while-in-use crash bug in ObjectPath
+Other changes
+-------------
+
+* The test suites now run ``gc.collect()`` in the ``tearDown()``
+ methods. While this makes them take a lot longer to run, it also
+ makes it easier to link a specific test to garbage collection
+ problems that would otherwise appear in later tests.
+
1.3.5 (2007-10-22)
==================
Modified: lxml/branch/lxml-1.3/src/lxml/tests/common_imports.py
==============================================================================
--- lxml/branch/lxml-1.3/src/lxml/tests/common_imports.py (original)
+++ lxml/branch/lxml-1.3/src/lxml/tests/common_imports.py Mon Oct 29 20:50:15 2007
@@ -1,7 +1,7 @@
import unittest
import os.path
from StringIO import StringIO
-import re
+import re, gc
from lxml import etree
@@ -30,6 +30,9 @@
return lambda obj: obj[item]
class HelperTestCase(unittest.TestCase):
+ def tearDown(self):
+ gc.collect()
+
def parse(self, text):
f = StringIO(text)
return etree.parse(f)
Modified: lxml/branch/lxml-1.3/src/lxml/tests/test_classlookup.py
==============================================================================
--- lxml/branch/lxml-1.3/src/lxml/tests/test_classlookup.py (original)
+++ lxml/branch/lxml-1.3/src/lxml/tests/test_classlookup.py Mon Oct 29 20:50:15 2007
@@ -31,6 +31,7 @@
etree.setElementClassLookup()
etree.Namespace("myNS").clear()
etree.Namespace("otherNS").clear()
+ super(ClassLookupTestCase, self).tearDown()
def test_namespace_lookup(self):
class TestElement(etree.ElementBase):
Modified: lxml/branch/lxml-1.3/src/lxml/tests/test_elementtree.py
==============================================================================
--- lxml/branch/lxml-1.3/src/lxml/tests/test_elementtree.py (original)
+++ lxml/branch/lxml-1.3/src/lxml/tests/test_elementtree.py Mon Oct 29 20:50:15 2007
@@ -18,10 +18,12 @@
etree = None
def setUp(self):
+ super(ETreeTestCaseBase, self).setUp()
self._temp_dir = tempfile.mkdtemp()
def tearDown(self):
shutil.rmtree(self._temp_dir)
+ super(ETreeTestCaseBase, self).tearDown()
def getTestFilePath(self, name):
return os.path.join(self._temp_dir, name)
Modified: lxml/branch/lxml-1.3/src/lxml/tests/test_htmlparser.py
==============================================================================
--- lxml/branch/lxml-1.3/src/lxml/tests/test_htmlparser.py (original)
+++ lxml/branch/lxml-1.3/src/lxml/tests/test_htmlparser.py Mon Oct 29 20:50:15 2007
@@ -10,7 +10,7 @@
from common_imports import StringIO, etree, fileInTestDir
from common_imports import SillyFileLike, HelperTestCase
-class HtmlParserTestCaseBase(HelperTestCase):
+class HtmlParserTestCase(HelperTestCase):
"""HTML parser test cases
"""
etree = etree
@@ -21,6 +21,7 @@
def tearDown(self):
self.etree.setDefaultParser()
+ super(HtmlParserTestCase, self).tearDown()
def test_module_HTML(self):
element = self.etree.HTML(self.html_str)
@@ -111,7 +112,7 @@
def test_suite():
suite = unittest.TestSuite()
- suite.addTests([unittest.makeSuite(HtmlParserTestCaseBase)])
+ suite.addTests([unittest.makeSuite(HtmlParserTestCase)])
return suite
if __name__ == '__main__':
Modified: lxml/branch/lxml-1.3/src/lxml/tests/test_io.py
==============================================================================
--- lxml/branch/lxml-1.3/src/lxml/tests/test_io.py (original)
+++ lxml/branch/lxml-1.3/src/lxml/tests/test_io.py Mon Oct 29 20:50:15 2007
@@ -5,7 +5,7 @@
"""
import unittest
-import tempfile, gzip, os
+import tempfile, gzip, os, gc
from common_imports import etree, ElementTree, fileInTestDir
from common_imports import SillyFileLike, LargeFileLike
@@ -22,6 +22,9 @@
self.root_str = self.etree.tostring(self.root)
self.tree = self.etree.ElementTree(self.root)
+ def tearDown(self):
+ gc.collect()
+
def test_write_filename(self):
# (c)ElementTree supports filename strings as write argument
Modified: lxml/branch/lxml-1.3/src/lxml/tests/test_nsclasses.py
==============================================================================
--- lxml/branch/lxml-1.3/src/lxml/tests/test_nsclasses.py (original)
+++ lxml/branch/lxml-1.3/src/lxml/tests/test_nsclasses.py Mon Oct 29 20:50:15 2007
@@ -21,6 +21,7 @@
return u'bluff'
def setUp(self):
+ super(ETreeNamespaceClassesTestCase, self).setUp()
parser = etree.XMLParser()
parser.setElementClassLookup(
etree.ElementNamespaceClassLookup() )
@@ -28,6 +29,7 @@
def tearDown(self):
etree.setDefaultParser()
+ super(ETreeNamespaceClassesTestCase, self).tearDown()
def test_registry(self):
ns = etree.Namespace(u'ns01')
Modified: lxml/branch/lxml-1.3/src/lxml/tests/test_objectify.py
==============================================================================
--- lxml/branch/lxml-1.3/src/lxml/tests/test_objectify.py (original)
+++ lxml/branch/lxml-1.3/src/lxml/tests/test_objectify.py Mon Oct 29 20:50:15 2007
@@ -60,6 +60,7 @@
return self.etree.XML(xml, self.parser)
def setUp(self):
+ super(ObjectifyTestCase, self).setUp()
self.parser = self.etree.XMLParser(remove_blank_text=True)
lookup = etree.ElementNamespaceClassLookup(
objectify.ObjectifyElementClassLookup() )
@@ -73,6 +74,7 @@
def tearDown(self):
self.etree.Namespace("otherNS").clear()
objectify.setPytypeAttributeTag()
+ super(ObjectifyTestCase, self).tearDown()
def test_element_nsmap_default(self):
elt = objectify.Element("test")
Modified: lxml/branch/lxml-1.3/src/lxml/tests/test_pyclasslookup.py
==============================================================================
--- lxml/branch/lxml-1.3/src/lxml/tests/test_pyclasslookup.py (original)
+++ lxml/branch/lxml-1.3/src/lxml/tests/test_pyclasslookup.py Mon Oct 29 20:50:15 2007
@@ -34,6 +34,7 @@
def tearDown(self):
self.parser.setElementClassLookup(None)
+ super(PyClassLookupTestCase, self).tearDown()
def _setClassLookup(self, lookup_function):
class Lookup(PythonElementClassLookup):
More information about the lxml-checkins
mailing list