[Neo-report] r2668 jm - in /trunk/neo: scripts/ tests/ tests/functional/
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Mar 17 15:47:11 CET 2011
Author: jm
Date: Thu Mar 17 15:47:10 2011
New Revision: 2668
Log:
tests: gather temporary folders in a subfolder to not pollute default /tmp
Modified:
trunk/neo/scripts/runner.py
trunk/neo/tests/__init__.py
trunk/neo/tests/functional/__init__.py
Modified: trunk/neo/scripts/runner.py
==============================================================================
--- trunk/neo/scripts/runner.py [iso-8859-1] (original)
+++ trunk/neo/scripts/runner.py [iso-8859-1] Thu Mar 17 15:47:10 2011
@@ -18,13 +18,13 @@
import traceback
import unittest
-import tempfile
import logging
import time
import sys
import neo
import os
+from neo.tests import getTempDirectory
from neo.tests.benchmark import BenchmarkRunner
# list of test modules
@@ -111,8 +111,7 @@ class NeoTestRunner(unittest.TestResult)
self.modulesStats = {}
self.failedImports = {}
self.lastStart = None
- self.temp_directory = tempfile.mkdtemp(prefix='neo_')
- print "Base directory : %s" % (self.temp_directory, )
+ self.temp_directory = getTempDirectory()
def run(self, name, modules):
print '\n', name
Modified: trunk/neo/tests/__init__.py
==============================================================================
--- trunk/neo/tests/__init__.py [iso-8859-1] (original)
+++ trunk/neo/tests/__init__.py [iso-8859-1] Thu Mar 17 15:47:10 2011
@@ -52,6 +52,24 @@ def buildUrlFromString(address):
pass
return address
+def getTempDirectory():
+ """get the current temp directory or a new one"""
+ try:
+ temp_dir = os.environ['TEMP']
+ except KeyError:
+ neo_dir = os.path.join(tempfile.gettempdir(), 'neo_tests')
+ while True:
+ temp_dir = os.path.join(neo_dir, repr(time()))
+ try:
+ os.makedirs(temp_dir)
+ break
+ except OSError, e:
+ if e.errno != errno.EEXIST:
+ raise
+ os.environ['TEMP'] = temp_dir
+ print 'Using temp directory %r.' % temp_dir
+ return temp_dir
+
class NeoTestBase(unittest.TestCase):
def setUp(self):
sys.stdout.write(' * %s ' % (self.id(), ))
Modified: trunk/neo/tests/functional/__init__.py
==============================================================================
--- trunk/neo/tests/functional/__init__.py [iso-8859-1] (original)
+++ trunk/neo/tests/functional/__init__.py [iso-8859-1] Thu Mar 17 15:47:10 2011
@@ -33,7 +33,7 @@ from neo.neoctl.neoctl import NeoCTL, No
from neo.lib.protocol import ClusterStates, NodeTypes, CellStates, NodeStates
from neo.lib.util import dump, SOCKET_CONNECTORS_DICT
from neo.tests import DB_ADMIN, DB_PASSWD, NeoTestBase, buildUrlFromString, \
- ADDRESS_TYPE, IP_VERSION_FORMAT_DICT, SocketLock
+ ADDRESS_TYPE, IP_VERSION_FORMAT_DICT, SocketLock, getTempDirectory
from neo.client.Storage import Storage
NEO_MASTER = 'neomaster'
@@ -613,14 +613,8 @@ class NEOCluster(object):
class NEOFunctionalTest(NeoTestBase):
def getTempDirectory(self):
- # get the current temp directory or a new one
- temp_dir = os.environ.get('TEMP', None)
- if temp_dir is None:
- temp_dir = tempfile.mkdtemp(prefix='neo_')
- os.environ['TEMP'] = temp_dir
- print 'Using temp directory %r.' % (temp_dir, )
# build the full path based on test case and current test method
- temp_dir = os.path.join(temp_dir, self.id())
+ temp_dir = os.path.join(getTempDirectory(), self.id())
# build the path if needed
if not os.path.exists(temp_dir):
os.makedirs(temp_dir)
More information about the Neo-report
mailing list