Commit 5ba54d6b authored by Vincent Pelletier's avatar Vincent Pelletier

Move test name display to setUp method, out of runner.

There is no reason why we wouldn't see this when runing individual
tests, I think.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2392 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 0961f1bd
......@@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import os
import sys
import random
import unittest
import tempfile
......@@ -33,6 +34,17 @@ DB_PASSWD = os.getenv('NEO_DB_PASSWD', None)
DB_USER = os.getenv('NEO_DB_USER', 'test')
class NeoTestBase(unittest.TestCase):
def setUp(self):
sys.stdout.write(' * %s ' % (self.id(), ))
sys.stdout.flush()
unittest.TestCase.setUp(self)
def tearDown(self):
unittest.TestCase.tearDown(self)
sys.stdout.write('\n')
sys.stdout.flush()
class NeoUnitTestBase(NeoTestBase):
""" Base class for neo tests, implements common checks """
def prepareDatabase(self, number, admin=DB_ADMIN, password=DB_PASSWD,
......
......@@ -20,7 +20,7 @@ import unittest
from cPickle import dumps
from mock import Mock, ReturnValues
from ZODB.POSException import StorageTransactionError, UndoError, ConflictError
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.client.app import Application
from neo.client.exception import NEOStorageError, NEOStorageNotFoundError
from neo.client.exception import NEOStorageDoesNotExistError
......@@ -57,7 +57,7 @@ def resolving_tryToResolveConflict(oid, conflict_serial, serial, data):
def failing_tryToResolveConflict(oid, conflict_serial, serial, data):
return None
class ClientApplicationTests(NeoTestBase):
class ClientApplicationTests(NeoUnitTestBase):
def setUp(self):
# apply monkey patches
......
......@@ -18,10 +18,10 @@
import unittest
from mock import Mock
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.client.app import ConnectionPool
class ConnectionPoolTests(NeoTestBase):
class ConnectionPoolTests(NeoUnitTestBase):
def test_removeConnection(self):
app = None
......
......@@ -17,7 +17,7 @@
import unittest
from mock import Mock, ReturnValues
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.pt import PartitionTable
from neo.protocol import NodeTypes, NodeStates
from neo.client.handlers.master import PrimaryBootstrapHandler
......@@ -28,7 +28,7 @@ from neo.client.exception import NEOStorageError
MARKER = []
class MasterHandlerTests(NeoTestBase):
class MasterHandlerTests(NeoUnitTestBase):
def setUp(self):
pass
......
......@@ -17,7 +17,7 @@
import unittest
from mock import Mock
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.protocol import NodeTypes, LockState
from neo.client.handlers.storage import StorageBootstrapHandler, \
StorageAnswersHandler
......@@ -27,7 +27,7 @@ from ZODB.POSException import ConflictError
MARKER = []
class StorageBootstrapHandlerTests(NeoTestBase):
class StorageBootstrapHandlerTests(NeoUnitTestBase):
def setUp(self):
self.app = Mock()
......@@ -64,7 +64,7 @@ class StorageBootstrapHandlerTests(NeoTestBase):
self.checkUUIDSet(conn, uuid)
class StorageAnswerHandlerTests(NeoTestBase):
class StorageAnswerHandlerTests(NeoUnitTestBase):
def setUp(self):
self.app = Mock()
......
......@@ -31,7 +31,7 @@ import threading
from neo.neoctl.neoctl import NeoCTL, NotReadyException
from neo.protocol import ClusterStates, NodeTypes, CellStates, NodeStates
from neo.util import dump
from neo.tests import DB_ADMIN, DB_PASSWD
from neo.tests import DB_ADMIN, DB_PASSWD, NeoTestBase
from neo.client.Storage import Storage
NEO_MASTER = 'neomaster'
......@@ -538,13 +538,14 @@ class NEOCluster(object):
os.removedirs(self.temp_dir)
class NEOFunctionalTest(unittest.TestCase):
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())
......
......@@ -18,12 +18,12 @@
import unittest
from mock import Mock
from struct import pack, unpack
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.protocol import NodeTypes, NodeStates, Packets
from neo.master.handlers.client import ClientServiceHandler
from neo.master.app import Application
class MasterClientHandlerTests(NeoTestBase):
class MasterClientHandlerTests(NeoUnitTestBase):
def setUp(self):
# create an application object
......@@ -47,7 +47,7 @@ class MasterClientHandlerTests(NeoTestBase):
self.app.nm.createStorage(**kw)
def tearDown(self):
NeoTestBase.tearDown(self)
NeoUnitTestBase.tearDown(self)
def getLastUUID(self):
return self.uuid
......
......@@ -18,7 +18,7 @@
import unittest
from mock import Mock
from neo import protocol
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.protocol import Packet, NodeTypes, NodeStates
from neo.master.handlers.election import ClientElectionHandler, ServerElectionHandler
from neo.master.app import Application
......@@ -31,7 +31,7 @@ def _addPacket(self, packet):
if self.connector is not None:
self.connector._addPacket(packet)
class MasterClientElectionTests(NeoTestBase):
class MasterClientElectionTests(NeoUnitTestBase):
def setUp(self):
# create an application object
......@@ -57,7 +57,7 @@ class MasterClientElectionTests(NeoTestBase):
def tearDown(self):
# restore patched methods
ClientConnection._addPacket = self._addPacket
NeoTestBase.tearDown(self)
NeoUnitTestBase.tearDown(self)
def identifyToMasterNode(self):
node = self.app.nm.getMasterList()[0]
......@@ -189,7 +189,7 @@ class MasterClientElectionTests(NeoTestBase):
self.checkRequestIdentification(conn)
class MasterServerElectionTests(NeoTestBase):
class MasterServerElectionTests(NeoUnitTestBase):
def setUp(self):
# create an application object
......@@ -213,7 +213,7 @@ class MasterServerElectionTests(NeoTestBase):
ClientConnection._addPacket = _addPacket
def tearDown(self):
NeoTestBase.tearDown(self)
NeoUnitTestBase.tearDown(self)
# restore environnement
ClientConnection._addPacket = self._addPacket
......
......@@ -17,11 +17,11 @@
import unittest
from mock import Mock
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.master.app import Application
from neo.util import p64, u64
class MasterAppTests(NeoTestBase):
class MasterAppTests(NeoUnitTestBase):
def setUp(self):
# create an application object
......@@ -30,7 +30,7 @@ class MasterAppTests(NeoTestBase):
self.app.pt.clear()
def tearDown(self):
NeoTestBase.tearDown(self)
NeoUnitTestBase.tearDown(self)
def test_06_broadcastNodeInformation(self):
# defined some nodes to which data will be send
......
......@@ -17,12 +17,12 @@
import unittest
from mock import Mock
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.protocol import NodeStates, CellStates
from neo.master.pt import PartitionTable
from neo.node import StorageNode
class MasterPartitionTableTests(NeoTestBase):
class MasterPartitionTableTests(NeoUnitTestBase):
def test_02_PartitionTable_creation(self):
num_partitions = 5
......
......@@ -17,12 +17,12 @@
import unittest
from struct import pack, unpack
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.protocol import NodeTypes, NodeStates, CellStates
from neo.master.recovery import RecoveryManager
from neo.master.app import Application
class MasterRecoveryTests(NeoTestBase):
class MasterRecoveryTests(NeoUnitTestBase):
def setUp(self):
# create an application object
......@@ -44,7 +44,7 @@ class MasterRecoveryTests(NeoTestBase):
self.storage_address = ('127.0.0.1', self.storage_port)
def tearDown(self):
NeoTestBase.tearDown(self)
NeoUnitTestBase.tearDown(self)
# Common methods
def getLastUUID(self):
......
......@@ -18,14 +18,14 @@
import unittest
from mock import Mock
from struct import pack
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.protocol import NodeTypes, NodeStates, Packets
from neo.master.handlers.storage import StorageServiceHandler
from neo.master.handlers.client import ClientServiceHandler
from neo.master.app import Application
from neo.exception import OperationFailure
class MasterStorageHandlerTests(NeoTestBase):
class MasterStorageHandlerTests(NeoUnitTestBase):
def setUp(self):
# create an application object
......@@ -44,7 +44,7 @@ class MasterStorageHandlerTests(NeoTestBase):
self.storage_address = ('127.0.0.1', self.storage_port)
def tearDown(self):
NeoTestBase.tearDown(self)
NeoUnitTestBase.tearDown(self)
def _allocatePort(self):
self.port = getattr(self, 'port', 1000) + 1
......
......@@ -18,11 +18,11 @@
import unittest
from mock import Mock
from struct import pack, unpack
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.master.transactions import Transaction, TransactionManager
class testTransactionManager(NeoTestBase):
class testTransactionManager(NeoUnitTestBase):
def makeTID(self, i):
return pack('!Q', i)
......
......@@ -17,13 +17,13 @@
import unittest
from struct import pack, unpack
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.protocol import NodeTypes, NodeStates
from neo.master.verification import VerificationManager, VerificationFailure
from neo.master.app import Application
class MasterVerificationTests(NeoTestBase):
class MasterVerificationTests(NeoUnitTestBase):
def setUp(self):
# create an application object
......@@ -45,7 +45,7 @@ class MasterVerificationTests(NeoTestBase):
self.storage_address = ('127.0.0.1', self.storage_port)
def tearDown(self):
NeoTestBase.tearDown(self)
NeoUnitTestBase.tearDown(self)
# Common methods
def getLastUUID(self):
......
......@@ -18,7 +18,7 @@
import unittest
from mock import Mock, ReturnValues
from collections import deque
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.storage.app import Application
from neo.storage.transactions import ConflictError, DelayedError
from neo.storage.handlers.client import ClientOperationHandler
......@@ -26,7 +26,7 @@ from neo.protocol import INVALID_PARTITION
from neo.protocol import INVALID_TID, INVALID_OID, INVALID_SERIAL
from neo.protocol import Packets, LockState
class StorageClientHandlerTests(NeoTestBase):
class StorageClientHandlerTests(NeoUnitTestBase):
def checkHandleUnexpectedPacket(self, _call, _msg_type, _listening=True, **kwargs):
conn = self.getFakeConnection(address=("127.0.0.1", self.master_port),
......@@ -55,7 +55,7 @@ class StorageClientHandlerTests(NeoTestBase):
self.master_port = 10010
def tearDown(self):
NeoTestBase.tearDown(self)
NeoUnitTestBase.tearDown(self)
def _getConnection(self, uuid=None):
return self.getFakeConnection(uuid=uuid, address=('127.0.0.1', 1000))
......
......@@ -17,13 +17,13 @@
import unittest
from mock import Mock
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.protocol import NodeTypes, NotReadyError, BrokenNodeDisallowedError
from neo.pt import PartitionTable
from neo.storage.app import Application
from neo.storage.handlers.identification import IdentificationHandler
class StorageIdentificationHandlerTests(NeoTestBase):
class StorageIdentificationHandlerTests(NeoUnitTestBase):
def setUp(self):
config = self.getStorageConfiguration(master_number=1)
......
......@@ -17,14 +17,14 @@
import unittest
from mock import Mock
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.pt import PartitionTable
from neo.storage.app import Application
from neo.storage.handlers.initialization import InitializationHandler
from neo.protocol import CellStates, ProtocolError
from neo.exception import PrimaryFailure
class StorageInitializationHandlerTests(NeoTestBase):
class StorageInitializationHandlerTests(NeoUnitTestBase):
def setUp(self):
self.prepareDatabase(number=1)
......@@ -43,7 +43,7 @@ class StorageInitializationHandlerTests(NeoTestBase):
self.app.pt = PartitionTable(self.num_partitions, self.num_replicas)
def tearDown(self):
NeoTestBase.tearDown(self)
NeoUnitTestBase.tearDown(self)
# Common methods
def getLastUUID(self):
......
......@@ -18,7 +18,7 @@
import unittest
from mock import Mock
from collections import deque
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.storage.app import Application
from neo.storage.handlers.master import MasterOperationHandler
from neo.exception import PrimaryFailure, OperationFailure
......@@ -26,7 +26,7 @@ from neo.pt import PartitionTable
from neo.protocol import CellStates, ProtocolError, Packets
from neo.protocol import INVALID_TID, INVALID_OID
class StorageMasterHandlerTests(NeoTestBase):
class StorageMasterHandlerTests(NeoUnitTestBase):
def checkHandleUnexpectedPacket(self, _call, _msg_type, _listening=True, **kwargs):
conn = self.getMasterConnection(is_server=_listening)
......@@ -53,7 +53,7 @@ class StorageMasterHandlerTests(NeoTestBase):
self.master_port = 10010
def tearDown(self):
NeoTestBase.tearDown(self)
NeoUnitTestBase.tearDown(self)
def getMasterConnection(self):
address = ("127.0.0.1", self.master_port)
......
......@@ -17,7 +17,7 @@
import unittest
from mock import Mock
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.protocol import Packets, ZERO_OID, ZERO_TID
from neo.storage.handlers.replication import ReplicationHandler, add64
from neo.storage.handlers.replication import RANGE_LENGTH, MIN_RANGE_LENGTH
......@@ -58,7 +58,7 @@ class FakeDict(object):
def __len__(self):
return len(self._dict)
class StorageReplicationHandlerTests(NeoTestBase):
class StorageReplicationHandlerTests(NeoUnitTestBase):
def setup(self):
pass
......
......@@ -17,11 +17,11 @@
import unittest
from mock import Mock, ReturnValues
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.storage.replicator import Replicator, Partition, Task
from neo.protocol import CellStates, NodeStates, Packets
class StorageReplicatorTests(NeoTestBase):
class StorageReplicatorTests(NeoUnitTestBase):
def setup(self):
pass
......
......@@ -17,14 +17,14 @@
import unittest
from mock import Mock
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.storage.app import Application
from neo.protocol import CellStates
from collections import deque
from neo.pt import PartitionTable
from neo.util import dump
class StorageAppTests(NeoTestBase):
class StorageAppTests(NeoUnitTestBase):
def setUp(self):
self.prepareDatabase(number=1)
......@@ -34,7 +34,7 @@ class StorageAppTests(NeoTestBase):
self.app.event_queue = deque()
def tearDown(self):
NeoTestBase.tearDown(self)
NeoUnitTestBase.tearDown(self)
def test_01_loadPartitionTable(self):
self.app.dm = Mock({
......
......@@ -18,13 +18,13 @@
import unittest
from mock import Mock
from collections import deque
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.storage.app import Application
from neo.storage.handlers.storage import StorageOperationHandler
from neo.protocol import INVALID_PARTITION, Packets
from neo.protocol import INVALID_TID, INVALID_OID, INVALID_SERIAL
class StorageStorageHandlerTests(NeoTestBase):
class StorageStorageHandlerTests(NeoUnitTestBase):
def checkHandleUnexpectedPacket(self, _call, _msg_type, _listening=True, **kwargs):
conn = self.getFakeConnection(address=("127.0.0.1", self.master_port),
......@@ -52,7 +52,7 @@ class StorageStorageHandlerTests(NeoTestBase):
self.master_port = 10010
def tearDown(self):
NeoTestBase.tearDown(self)
NeoUnitTestBase.tearDown(self)
def test_18_askTransactionInformation1(self):
# transaction does not exists
......
......@@ -20,14 +20,14 @@ import MySQLdb
from mock import Mock
from neo.util import dump, p64, u64
from neo.protocol import CellStates, ZERO_OID, ZERO_TID, MAX_TID
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.exception import DatabaseFailure
from neo.storage.database.mysqldb import MySQLDatabaseManager
NEO_SQL_DATABASE = 'test_mysqldb0'
NEO_SQL_USER = 'test'
class StorageMySQSLdbTests(NeoTestBase):
class StorageMySQSLdbTests(NeoUnitTestBase):
def setUp(self):
self.prepareDatabase(number=1, prefix=NEO_SQL_DATABASE[:-1])
......
......@@ -18,12 +18,12 @@
import unittest
from mock import Mock
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.storage.transactions import Transaction, TransactionManager
from neo.storage.transactions import ConflictError, DelayedError
class TransactionTests(NeoTestBase):
class TransactionTests(NeoUnitTestBase):
def testInit(self):
uuid = self.getNewUUID()
......@@ -79,7 +79,7 @@ class TransactionTests(NeoTestBase):
self.assertEqual(txn.getObject(oid_2), None)
self.assertEqual(txn.getObject(oid_1), object_info)
class TransactionManagerTests(NeoTestBase):
class TransactionManagerTests(NeoUnitTestBase):
def setUp(self):
self.app = Mock()
......
......@@ -17,7 +17,7 @@
import unittest
from mock import Mock
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.pt import PartitionTable
from neo.storage.app import Application
from neo.storage.handlers.verification import VerificationHandler
......@@ -26,7 +26,7 @@ from neo.protocol import INVALID_OID, INVALID_TID
from neo.exception import PrimaryFailure, OperationFailure
from neo.util import p64, u64
class StorageVerificationHandlerTests(NeoTestBase):
class StorageVerificationHandlerTests(NeoUnitTestBase):
def setUp(self):
self.prepareDatabase(number=1)
......@@ -46,7 +46,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
def tearDown(self):
NeoTestBase.tearDown(self)
NeoUnitTestBase.tearDown(self)
# Common methods
def getLastUUID(self):
......
......@@ -17,12 +17,12 @@
import unittest
from mock import Mock
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.storage.app import Application
from neo.bootstrap import BootstrapManager
from neo.protocol import NodeTypes
class BootstrapManagerTests(NeoTestBase):
class BootstrapManagerTests(NeoUnitTestBase):
def setUp(self):
self.prepareDatabase(number=1)
......@@ -37,7 +37,7 @@ class BootstrapManagerTests(NeoTestBase):
self.num_replicas = 2
def tearDown(self):
NeoTestBase.tearDown(self)
NeoUnitTestBase.tearDown(self)
# Common methods
def getLastUUID(self):
......
......@@ -25,11 +25,11 @@ from neo.tests import DoNothingConnector
from neo.connector import ConnectorException, ConnectorTryAgainException, \
ConnectorInProgressException, ConnectorConnectionRefusedException
from neo.protocol import Packets, ParserState
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.util import ReadBuffer
from neo.locking import Queue
class ConnectionTests(NeoTestBase):
class ConnectionTests(NeoUnitTestBase):
def setUp(self):
self.app = Mock({'__repr__': 'Fake App'})
......@@ -834,7 +834,7 @@ class MTConnectionTests(ConnectionTests):
# ... except Ping
ask(Packets.Ping())
class HandlerSwitcherTests(NeoTestBase):
class HandlerSwitcherTests(NeoUnitTestBase):
def setUp(self):
self._handler = handler = Mock({
......@@ -1088,7 +1088,7 @@ class HandlerSwitcherTests(NeoTestBase):
# ...with expected parameters
self.assertEqual(markers[0], (4, self._connection, msg_id_4))
class TestTimeout(NeoTestBase):
class TestTimeout(NeoUnitTestBase):
def setUp(self):
self.current = time()
self.timeout = Timeout()
......
......@@ -17,11 +17,11 @@
import unittest
from mock import Mock
from time import time
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.epoll import Epoll
from neo.event import EpollEventManager
class EventTests(NeoTestBase):
class EventTests(NeoUnitTestBase):
def setUp(self):
pass
......
......@@ -17,12 +17,12 @@
import unittest
from mock import Mock
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.handler import EventHandler
from neo.protocol import PacketMalformedError, UnexpectedPacketError, \
BrokenNodeDisallowedError, NotReadyError, ProtocolError
class HandlerTests(NeoTestBase):
class HandlerTests(NeoUnitTestBase):
def setUp(self):
app = Mock()
......
......@@ -21,10 +21,10 @@ from neo import protocol
from neo.protocol import NodeTypes, NodeStates
from neo.node import Node, MasterNode, StorageNode, ClientNode, AdminNode, \
NodeManager
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from time import time
class NodesTests(NeoTestBase):
class NodesTests(NeoUnitTestBase):
def setUp(self):
self.manager = Mock()
......@@ -122,7 +122,7 @@ class NodesTests(NeoTestBase):
self.assertFalse(node.isClient())
class NodeManagerTests(NeoTestBase):
class NodeManagerTests(NeoUnitTestBase):
def setUp(self):
self.manager = NodeManager()
......
......@@ -20,9 +20,9 @@ from mock import Mock
from neo.protocol import NodeStates, CellStates
from neo.pt import Cell, PartitionTable
from neo.node import StorageNode
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
class PartitionTableTests(NeoTestBase):
class PartitionTableTests(NeoUnitTestBase):
def test_01_Cell(self):
uuid = self.getNewUUID()
......
......@@ -19,9 +19,9 @@ import unittest
from neo.protocol import NodeTypes, NodeStates, CellStates, ClusterStates
from neo.protocol import ErrorCodes, Packets, Errors, LockState
from neo.protocol import INVALID_TID
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
class ProtocolTests(NeoTestBase):
class ProtocolTests(NeoUnitTestBase):
def setUp(self):
self.ltid = None
......
......@@ -17,10 +17,10 @@
import unittest
from neo.tests import NeoTestBase
from neo.tests import NeoUnitTestBase
from neo.util import ReadBuffer
class UtilTests(NeoTestBase):
class UtilTests(NeoUnitTestBase):
def testReadBufferRead(self):
""" Append some chunk then consume the data """
......
......@@ -152,10 +152,6 @@ class NeoTestRunner(unittest.TestResult):
stats.time += time.time() - self.lastStart
def startTest(self, test):
module = test.__class__.__name__