[Erp5-report] r34864 jm - /erp5/trunk/products/ERP5SyncML/tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Apr 29 19:47:21 CEST 2010


Author: jm
Date: Thu Apr 29 19:47:19 2010
New Revision: 34864

URL: http://svn.erp5.org?rev=34864&view=rev
Log:
Do not use /tmp selfishly

IOW, be nice with the OS and other software/users.

- /tmp should never be hardcoded: $TMPDIR is better
- $TMPDIR should be only used with 'tempfile' and appropriate clean up
- in unit tests, the 'tests' directory can be used as temporary storage
  (like in this commit)

This fixes possible random failures of SyncML related tests when, for example,
testERP5SyncML and testERP5DocumentSyncML are run in parallel.

Modified:
    erp5/trunk/products/ERP5SyncML/tests/testERP5DocumentSyncML.py
    erp5/trunk/products/ERP5SyncML/tests/testERP5SyncML.py

Modified: erp5/trunk/products/ERP5SyncML/tests/testERP5DocumentSyncML.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/tests/testERP5DocumentSyncML.py?rev=34864&r1=34863&r2=34864&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/tests/testERP5DocumentSyncML.py [utf8] (original)
+++ erp5/trunk/products/ERP5SyncML/tests/testERP5DocumentSyncML.py [utf8] Thu Apr 29 19:47:19 2010
@@ -30,6 +30,7 @@
 import os
 import unittest
 from Testing import ZopeTestCase
+from runUnitTest import tests_home
 from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
 from AccessControl.SecurityManagement import newSecurityManager
 from Products.ERP5SyncML.Conduit.ERP5DocumentConduit import ERP5DocumentConduit
@@ -100,9 +101,9 @@
   pub_conduit = 'ERP5DocumentConduit'
   sub_conduit1 = 'ERP5DocumentConduit'
   activity_enabled = True
-  publication_url = 'file://tmp/sync_server'
-  subscription_url = { 'two_way' : 'file://tmp/sync_client1', \
-        'from_server' : 'file://tmp/sync_client_from_server'}
+  publication_url = 'file:/%s/sync_server' % tests_home
+  subscription_url = {'two_way': 'file:/%s/sync_client1' % tests_home,
+      'from_server': 'file:/%s/sync_client_from_server' % tests_home}
   #for this tests
   nb_message_first_synchronization = 12
   nb_message_multi_first_synchronization = 14

Modified: erp5/trunk/products/ERP5SyncML/tests/testERP5SyncML.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/tests/testERP5SyncML.py?rev=34864&r1=34863&r2=34864&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/tests/testERP5SyncML.py [utf8] (original)
+++ erp5/trunk/products/ERP5SyncML/tests/testERP5SyncML.py [utf8] Thu Apr 29 19:47:19 2010
@@ -29,6 +29,7 @@
 
 import unittest
 from Testing import ZopeTestCase
+from runUnitTest import tests_home
 from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
 from AccessControl.SecurityManagement import newSecurityManager
 from Products.ERP5SyncML.Conduit.ERP5Conduit import ERP5Conduit
@@ -38,6 +39,7 @@
 import transaction
 from ERP5Diff import ERP5Diff
 from lxml import etree
+
 
 class TestERP5SyncMLMixin:
 
@@ -77,9 +79,15 @@
   nb_synchronization = 3
   nb_message_first_synchronization = 10
   nb_message_first_sync_max_lines = 10
-  subscription_url1 = 'file://tmp/sync_client1'
-  subscription_url2 = 'file://tmp/sync_client2'
-  publication_url = 'file://tmp/sync_server'
+  _subscription_url1 = tests_home + '/sync_client1'
+  _subscription_url2 = tests_home + '/sync_client2'
+  _publication_url = tests_home + '/sync_server'
+  # XXX Why the prefix is not 'file://' ? This is inconsistent with urlopen:
+  #     urlopen('file://tmp/foo') -> ERROR
+  #     urlopen('file:///tmp/foo') -> OK
+  subscription_url1 = 'file:/' + _subscription_url1
+  subscription_url2 = 'file:/' + _subscription_url2
+  publication_url = 'file:/' + _publication_url
   activity_enabled = False
   #publication_url = 'server at localhost'
   #subscription_url1 = 'client1 at localhost'
@@ -204,13 +212,13 @@
         publication = pub
     self.assertTrue(publication is not None)
     # reset files, because we do sync by files
-    file = open('/tmp/sync_client1', 'w')
+    file = open(self._subscription_url1, 'w')
     file.write('')
     file.close()
-    file = open('/tmp/sync_client2', 'w')
+    file = open(self._subscription_url2, 'w')
     file.write('')
     file.close()
-    file = open('/tmp/sync_server', 'w')
+    file = open(self._publication_url, 'w')
     file.write('')
     file.close()
     nb_message = 1
@@ -241,13 +249,13 @@
         publication = pub
     self.assertTrue(publication is not None)
     # reset files, because we do sync by files
-    file = open('/tmp/sync_client1', 'w')
+    file = open(self._subscription_url1, 'w')
     file.write('')
     file.close()
-    file = open('/tmp/sync_client2', 'w')
+    file = open(self._subscription_url2, 'w')
     file.write('')
     file.close()
-    file = open('/tmp/sync_server', 'w')
+    file = open(self._publication_url, 'w')
     file.write('')
     file.close()
     nb_message = 1




More information about the Erp5-report mailing list