[Checkins] SVN: Products.GenericSetup/trunk/ Add handling for cases where a report for an import already exists.
Patrick Gerken
do3ccqrv at gmail.com
Tue Apr 12 21:02:26 EDT 2011
Log message for revision 121416:
Add handling for cases where a report for an import already exists.
This can happen in fast tests. The code now starts incrementing an id
until it has an unused id.
Changed:
U Products.GenericSetup/trunk/Products/GenericSetup/tests/test_tool.py
U Products.GenericSetup/trunk/Products/GenericSetup/tool.py
U Products.GenericSetup/trunk/docs/CHANGES.rst
-=-
Modified: Products.GenericSetup/trunk/Products/GenericSetup/tests/test_tool.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/tests/test_tool.py 2011-04-12 19:20:41 UTC (rev 121415)
+++ Products.GenericSetup/trunk/Products/GenericSetup/tests/test_tool.py 2011-04-13 01:02:26 UTC (rev 121416)
@@ -385,6 +385,23 @@
self.assertEqual( len(result['steps']), 3 )
+ def test_runAllImportStepsFromProfile_inquicksuccession(self):
+ """
+ This test provokes an issue that only appears in testing.
+ There it can happen that profiles get run multiple times within
+ a second. As of 1.6.3, genericsetup does not handle this.
+ """
+
+ site = self._makeSite()
+ tool = self._makeOne('setup_tool').__of__( site )
+
+ tool.runAllImportStepsFromProfile('snapshot-dummy')
+ tool.runAllImportStepsFromProfile('snapshot-dummy')
+ # For good measurement
+ tool.runAllImportStepsFromProfile('snapshot-dummy')
+
+ self.assertTrue("No exception thrown")
+
def test_runAllImportStepsFromProfile_sorted_default_purge(self):
TITLE = 'original title'
Modified: Products.GenericSetup/trunk/Products/GenericSetup/tool.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/tool.py 2011-04-12 19:20:41 UTC (rev 121415)
+++ Products.GenericSetup/trunk/Products/GenericSetup/tool.py 2011-04-13 01:02:26 UTC (rev 121416)
@@ -1119,7 +1119,7 @@
return fmt % items
security.declarePrivate('_createReport')
- def _createReport(self, name, steps, messages):
+ def _createReport(self, basename, steps, messages):
""" Record the results of a run.
"""
lines = []
@@ -1137,14 +1137,21 @@
report = report.encode('latin-1')
# BBB: ObjectManager won't allow unicode IDS
- if isinstance(name, unicode):
- name = name.encode('UTF-8')
+ if isinstance(basename, unicode):
+ basename = basename.encode('UTF-8')
+ name = basename
+ index = 0
+ while name in self:
+ index += 1
+ name = basename + '_%i' % index
+
file = File(id=name,
title='',
file=report,
content_type='text/plain'
)
+
self._setObject(name, file)
InitializeClass(SetupTool)
Modified: Products.GenericSetup/trunk/docs/CHANGES.rst
===================================================================
--- Products.GenericSetup/trunk/docs/CHANGES.rst 2011-04-12 19:20:41 UTC (rev 121415)
+++ Products.GenericSetup/trunk/docs/CHANGES.rst 2011-04-13 01:02:26 UTC (rev 121416)
@@ -4,7 +4,11 @@
1.6.4 (unreleased)
------------------
+- If profiles get imported multiple times within a second, generate new
+ ids for each profile. This removes spurious failures in fast tests
+ of packages that use GenericSetup.
+
1.6.3 (2011-04-02)
------------------
More information about the checkins
mailing list