Commit 7368ce22 authored by Julien Muchembled's avatar Julien Muchembled

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.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34864 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cfbbe04f
......@@ -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 @@ class TestERP5DocumentSyncMLMixin:
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
......
......@@ -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
......@@ -39,6 +40,7 @@ import transaction
from ERP5Diff import ERP5Diff
from lxml import etree
class TestERP5SyncMLMixin:
# Different variables used for this test
......@@ -77,9 +79,15 @@ class TestERP5SyncMLMixin:
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@localhost'
#subscription_url1 = 'client1@localhost'
......@@ -204,13 +212,13 @@ class TestERP5SyncMLMixin:
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 @@ class TestERP5SyncMLMixin:
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment