[Lxml-checkins] r54346 - in lxml/trunk: . src/lxml/tests

scoder at codespeak.net scoder at codespeak.net
Fri May 2 20:00:03 CEST 2008


Author: scoder
Date: Fri May  2 20:00:03 2008
New Revision: 54346

Added:
   lxml/trunk/src/lxml/tests/test_threading.py
Modified:
   lxml/trunk/   (props changed)
Log:
 r4131 at delle:  sbehnel | 2008-05-02 19:58:26 +0200
 new test suite for threading tests


Added: lxml/trunk/src/lxml/tests/test_threading.py
==============================================================================
--- (empty file)
+++ lxml/trunk/src/lxml/tests/test_threading.py	Fri May  2 20:00:03 2008
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+
+"""
+Tests for thread usage in lxml.etree.
+"""
+
+import unittest, threading
+
+from common_imports import etree, HelperTestCase
+
+class ThreadingTestCase(HelperTestCase):
+    """Threading tests"""
+    etree = etree
+
+    def test_subtree_copy(self):
+        tostring = self.etree.tostring
+        XML = self.etree.XML
+        xml = "<root><threadtag/></root>"
+        main_root = XML("<root/>")
+
+        def run_thread():
+            thread_root = XML(xml)
+            main_root.append(thread_root[0])
+            del thread_root
+
+        thread = threading.Thread(target=run_thread)
+        thread.start()
+        thread.join()
+
+        self.assertEquals(xml, tostring(main_root))
+
+def test_suite():
+    suite = unittest.TestSuite()
+    suite.addTests([unittest.makeSuite(ThreadingTestCase)])
+    return suite
+
+if __name__ == '__main__':
+    print 'to test use test.py %s' % __file__


More information about the lxml-checkins mailing list