Commit ed51b0d4 authored by Julien Muchembled's avatar Julien Muchembled

Unit test: Workaround for weird error if 'random' module is imported too early

[30400] broke testBPMEvaluation when it is started without portal_id specified
(and if ERP5TypeTestCase.startZServer is called):

> Loading Zope ... Cleaning static files ... Instance at '[...]/unit_test' loaded ... done (5.998s)
> Adding ERP5TypeTestCase user ...
> Adding erp5_portal_553c666ce5a578fdf3fa486c77b3ccc7 ERP5 Site ... done (25.724s)
> Running ZServer on port 55251
> [...]
> Adding erp5_bpm business template ... (imported in 1.002s) done (6.688s)
> [...]
> Ran Unit test of <class 'testBPMEvaluation.TestOrderDefaultProcess'>
> ..........
> Adding ERP5TypeTestCase user ...
> Adding erp5_portal_8181974da49d954fafc6fb4b4934482e ERP5 Site ... done (27.120s)
> [...]
> Adding erp5_bpm business template ... (imported in 1.192s) Traceback (most recent call last):
>   File "[...]/Products/ERP5Type/tests/ERP5TypeTestCase.py", line 891, in setUpERP5Site
>     update_translation=1)
> [...]
>   File "[...]/ZODB/serialize.py", line 338, in _dump
>     self._p.dump(classmeta)
> PicklingError: Can't pickle <class 'Products.ERP5Type.Document.DeliveryBuilder.DeliveryBuilder'>: it's not the same object as Products.ERP5Type.Document.DeliveryBuilder.DeliveryBuilder
> [...]

On my machine with r30400, testBPMEvaluation fails randomly if 'import random'
line is moved just before line 156:

> import random
> ZopeTestCase.installProduct('PluggableAuthService', quiet=install_product_quiet)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30411 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 12db67c0
...@@ -11,7 +11,7 @@ import base64 ...@@ -11,7 +11,7 @@ import base64
import errno import errno
import md5 import md5
import os import os
import random #import random # XXX
import re import re
import socket import socket
import sys import sys
...@@ -728,6 +728,7 @@ class ERP5TypeTestCase(backportUnittest.TestCase, PortalTestCase): ...@@ -728,6 +728,7 @@ class ERP5TypeTestCase(backportUnittest.TestCase, PortalTestCase):
"""Starts an HTTP ZServer thread.""" """Starts an HTTP ZServer thread."""
from Testing.ZopeTestCase import threadutils, utils from Testing.ZopeTestCase import threadutils, utils
if utils._Z2HOST is None: if utils._Z2HOST is None:
import random
randint = random.Random(hash(os.environ['INSTANCE_HOME'])).randint randint = random.Random(hash(os.environ['INSTANCE_HOME'])).randint
def zserverRunner(): def zserverRunner():
try: try:
......
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