Commit d96c8d10 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

py2/py3: modernize -f print.

(not yet for scripts under portal_skins)

adjusted (by Jérome) to just remove call to print in a few places where
it made more sense.
parent 3306cfd1
from __future__ import print_function
from BTrees.LOBTree import LOBTree from BTrees.LOBTree import LOBTree
from persistent import Persistent from persistent import Persistent
import itertools import itertools
...@@ -314,7 +315,7 @@ class BTreeData(Persistent): ...@@ -314,7 +315,7 @@ class BTreeData(Persistent):
if __name__ == '__main__': if __name__ == '__main__':
def check(tree, length, read_offset, read_length, data_, keys=None): def check(tree, length, read_offset, read_length, data_, keys=None):
print list(tree._tree.items()) print(list(tree._tree.items()))
tree_length = len(tree) tree_length = len(tree)
tree_data = tree.read(read_offset, read_length) tree_data = tree.read(read_offset, read_length)
tree_iterator_data = ''.join(tree.iterate(read_offset, read_length)) tree_iterator_data = ''.join(tree.iterate(read_offset, read_length))
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
# #
############################################################################## ##############################################################################
from __future__ import print_function
import random import random
import time import time
...@@ -69,7 +70,7 @@ class TestRamCache(ERP5TypeTestCase): ...@@ -69,7 +70,7 @@ class TestRamCache(ERP5TypeTestCase):
for cache_plugin in filtered_cache_plugins: for cache_plugin in filtered_cache_plugins:
if not self.quiet: if not self.quiet:
print "TESTING (scope): ", cache_plugin print("TESTING (scope): ", cache_plugin)
## clear cache for this plugin ## clear cache for this plugin
cache_plugin.clearCache() cache_plugin.clearCache()
...@@ -85,7 +86,7 @@ class TestRamCache(ERP5TypeTestCase): ...@@ -85,7 +86,7 @@ class TestRamCache(ERP5TypeTestCase):
## we set ONLY one value per scope -> check if we get the same cache_id ## we set ONLY one value per scope -> check if we get the same cache_id
self.assertEqual([cache_id], cache_plugin.getScopeKeyList(scope)) self.assertEqual([cache_id], cache_plugin.getScopeKeyList(scope))
if not self.quiet: if not self.quiet:
print "\t", cache_id, scope, "\t\tOK" print("\t", cache_id, scope, "\t\tOK")
## get list of scopes which must be the same as test_scopes since we clear cache initially ## get list of scopes which must be the same as test_scopes since we clear cache initially
scopes_from_cache = cache_plugin.getScopeList() scopes_from_cache = cache_plugin.getScopeList()
...@@ -118,7 +119,7 @@ class TestRamCache(ERP5TypeTestCase): ...@@ -118,7 +119,7 @@ class TestRamCache(ERP5TypeTestCase):
def generalExpire(self, cache_plugin, iterations): def generalExpire(self, cache_plugin, iterations):
if not self.quiet: if not self.quiet:
print "TESTING (expire): ", cache_plugin print("TESTING (expire): ", cache_plugin)
base_timeout = 1 base_timeout = 1
values = self.prepareValues(iterations) values = self.prepareValues(iterations)
scope = "peter" scope = "peter"
...@@ -128,7 +129,7 @@ class TestRamCache(ERP5TypeTestCase): ...@@ -128,7 +129,7 @@ class TestRamCache(ERP5TypeTestCase):
cache_timeout = base_timeout + random.random()*2 cache_timeout = base_timeout + random.random()*2
cache_id = "mycache_id_to_expire_%s" %(count) cache_id = "mycache_id_to_expire_%s" %(count)
if not self.quiet: if not self.quiet:
print "\t", cache_id, " ==> timeout (s) = ", cache_timeout, print("\t", cache_id, " ==> timeout (s) = ", cache_timeout, end=' ')
## set to cache ## set to cache
cache_plugin.set(cache_id, scope, value, cache_timeout) cache_plugin.set(cache_id, scope, value, cache_timeout)
...@@ -142,11 +143,11 @@ class TestRamCache(ERP5TypeTestCase): ...@@ -142,11 +143,11 @@ class TestRamCache(ERP5TypeTestCase):
## check it, we MUST NOT have this key any more in cache ## check it, we MUST NOT have this key any more in cache
self.assertEqual(False, cache_plugin.has_key(cache_id, scope)) self.assertEqual(False, cache_plugin.has_key(cache_id, scope))
if not self.quiet: if not self.quiet:
print "\t\tOK" print("\t\tOK")
def generaltestSetGet(self, cache_plugin, iterations): def generaltestSetGet(self, cache_plugin, iterations):
if not self.quiet: if not self.quiet:
print "TESTING (set/get/has/del): ", cache_plugin print("TESTING (set/get/has/del): ", cache_plugin)
values = self.prepareValues(iterations) values = self.prepareValues(iterations)
cache_duration = 30 cache_duration = 30
scope = "peter" scope = "peter"
...@@ -158,7 +159,7 @@ class TestRamCache(ERP5TypeTestCase): ...@@ -158,7 +159,7 @@ class TestRamCache(ERP5TypeTestCase):
## set to cache ## set to cache
cache_plugin.set(cache_id, scope, value, cache_duration) cache_plugin.set(cache_id, scope, value, cache_duration)
if not self.quiet: if not self.quiet:
print "\t", cache_id, print("\t", cache_id, end=' ')
## check has_key() ## check has_key()
self.assertEqual(True, cache_plugin.has_key(cache_id, scope)) self.assertEqual(True, cache_plugin.has_key(cache_id, scope))
...@@ -184,7 +185,7 @@ class TestRamCache(ERP5TypeTestCase): ...@@ -184,7 +185,7 @@ class TestRamCache(ERP5TypeTestCase):
self.assertEqual(False, cache_plugin.has_key(cache_id, scope)) self.assertEqual(False, cache_plugin.has_key(cache_id, scope))
if not self.quiet: if not self.quiet:
print "\t\tOK" print("\t\tOK")
def prepareValues(self, iterations): def prepareValues(self, iterations):
""" generate a big list of values """ """ generate a big list of values """
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
# #
############################################################################## ##############################################################################
from __future__ import print_function
import time import time
import unittest import unittest
...@@ -227,9 +228,9 @@ return result ...@@ -227,9 +228,9 @@ return result
def _cacheFactoryInstanceTest(self, my_cache, cf_name, clear_allowed): def _cacheFactoryInstanceTest(self, my_cache, cf_name, clear_allowed):
portal = self.portal portal = self.portal
print print()
print "="*40 print("="*40)
print "TESTING:", cf_name print("TESTING:", cf_name)
result = 'a short value' result = 'a short value'
#portal.portal_caches.clearCacheFactory(cf_name) #portal.portal_caches.clearCacheFactory(cf_name)
...@@ -249,12 +250,12 @@ return result ...@@ -249,12 +250,12 @@ return result
result=result) result=result)
## 1st call ## 1st call
calculation_time = callCache(real_calculation=True) calculation_time = callCache(real_calculation=True)
print "\n\tCalculation time (1st call)", calculation_time print("\n\tCalculation time (1st call)", calculation_time)
self.commit() self.commit()
## 2nd call - should be cached now ## 2nd call - should be cached now
calculation_time = callCache(real_calculation=False) calculation_time = callCache(real_calculation=False)
print "\n\tCalculation time (2nd call)", calculation_time print("\n\tCalculation time (2nd call)", calculation_time)
self.commit() self.commit()
## OK so far let's clear cache ## OK so far let's clear cache
...@@ -263,10 +264,10 @@ return result ...@@ -263,10 +264,10 @@ return result
## 1st call ## 1st call
calculation_time = callCache(real_calculation=True) calculation_time = callCache(real_calculation=True)
print "\n\tCalculation time (after cache clear)", calculation_time print("\n\tCalculation time (after cache clear)", calculation_time)
# Test delete method on CachingMethod # Test delete method on CachingMethod
print "\n\tCalculation time (3rd call)", calculation_time print("\n\tCalculation time (3rd call)", calculation_time)
# make sure cache id filled # make sure cache id filled
calculation_time = callCache(real_calculation=False) calculation_time = callCache(real_calculation=False)
...@@ -275,7 +276,7 @@ return result ...@@ -275,7 +276,7 @@ return result
# Check that result is computed # Check that result is computed
calculation_time = callCache(real_calculation=True) calculation_time = callCache(real_calculation=True)
print "\n\tCalculation time (4th call)", calculation_time print("\n\tCalculation time (4th call)", calculation_time)
self.commit() self.commit()
def test_03_cachePersistentObjects(self): def test_03_cachePersistentObjects(self):
...@@ -296,9 +297,9 @@ return result ...@@ -296,9 +297,9 @@ return result
def test_04_CheckConcurrentRamCacheDict(self): def test_04_CheckConcurrentRamCacheDict(self):
"""Check that all RamCache doesn't clear the same cache_dict """Check that all RamCache doesn't clear the same cache_dict
""" """
print print()
print "="*40 print("="*40)
print "TESTING: Concurrent RamCache" print("TESTING: Concurrent RamCache")
portal = self.portal portal = self.portal
result = 'Something short' result = 'Something short'
...@@ -317,7 +318,7 @@ return result ...@@ -317,7 +318,7 @@ return result
result=result) result=result)
end = time.time() end = time.time()
calculation_time = end-start calculation_time = end-start
print "\n\tCalculation time (1st call)", calculation_time print("\n\tCalculation time (1st call)", calculation_time)
self.assertEqual(cached, result) self.assertEqual(cached, result)
self.commit() self.commit()
...@@ -328,7 +329,7 @@ return result ...@@ -328,7 +329,7 @@ return result
result=result) result=result)
end = time.time() end = time.time()
calculation_time = end-start calculation_time = end-start
print "\n\tCalculation time (2nd call)", calculation_time print("\n\tCalculation time (2nd call)", calculation_time)
self.assertTrue(1.0 > calculation_time, "1.0 <= %s" % calculation_time) self.assertTrue(1.0 > calculation_time, "1.0 <= %s" % calculation_time)
self.assertEqual(cached, result) self.assertEqual(cached, result)
self.commit() self.commit()
...@@ -342,7 +343,7 @@ return result ...@@ -342,7 +343,7 @@ return result
result=result) result=result)
end = time.time() end = time.time()
calculation_time = end-start calculation_time = end-start
print "\n\tCalculation time (3rd call)", calculation_time print("\n\tCalculation time (3rd call)", calculation_time)
self.assertTrue(1.0 > calculation_time, "1.0 <= %s" % calculation_time) self.assertTrue(1.0 > calculation_time, "1.0 <= %s" % calculation_time)
self.assertEqual(cached, result) self.assertEqual(cached, result)
self.commit() self.commit()
...@@ -351,9 +352,9 @@ return result ...@@ -351,9 +352,9 @@ return result
"""Check that persistent distributed Cache Plugin can handle keys """Check that persistent distributed Cache Plugin can handle keys
more than 250 bytes and values more than 1024 bytes. more than 250 bytes and values more than 1024 bytes.
""" """
print print()
print '=' * 40 print('=' * 40)
print 'TESTING: Long Keys and Large values' print('TESTING: Long Keys and Large values')
portal = self.portal portal = self.portal
# import the local and clear it # import the local and clear it
from Products.ERP5Type.CachePlugins.DistributedRamCache import\ from Products.ERP5Type.CachePlugins.DistributedRamCache import\
...@@ -410,7 +411,7 @@ return 'a' * 1024 * 1024 * 25 ...@@ -410,7 +411,7 @@ return 'a' * 1024 * 1024 * 25
long_parameter=long_parameter) long_parameter=long_parameter)
end = time.time() end = time.time()
calculation_time = end-start calculation_time = end-start
print "\n\tCalculation time (1st call)", calculation_time print("\n\tCalculation time (1st call)", calculation_time)
self.assertEqual(cached, result) self.assertEqual(cached, result)
self.commit() self.commit()
...@@ -423,7 +424,7 @@ return 'a' * 1024 * 1024 * 25 ...@@ -423,7 +424,7 @@ return 'a' * 1024 * 1024 * 25
long_parameter=long_parameter) long_parameter=long_parameter)
end = time.time() end = time.time()
calculation_time = end-start calculation_time = end-start
print "\n\tCalculation time (2nd call)", calculation_time print("\n\tCalculation time (2nd call)", calculation_time)
self.assertTrue(1.0 > calculation_time, "1.0 <= %s" % calculation_time) self.assertTrue(1.0 > calculation_time, "1.0 <= %s" % calculation_time)
self.assertEqual(cached, result) self.assertEqual(cached, result)
self.commit() self.commit()
...@@ -431,37 +432,37 @@ return 'a' * 1024 * 1024 * 25 ...@@ -431,37 +432,37 @@ return 'a' * 1024 * 1024 * 25
def test_06_CheckCacheExpiration(self): def test_06_CheckCacheExpiration(self):
"""Check that expiracy is well handle by Cache Plugins """Check that expiracy is well handle by Cache Plugins
""" """
print print()
print "="*40 print("="*40)
print "TESTING: Cache Expiration Time" print("TESTING: Cache Expiration Time")
py_script_obj = getattr(self.portal, self.python_script_id) py_script_obj = getattr(self.portal, self.python_script_id)
cache_factory_list = ('ram_cache_factory', 'distributed_ram_cache_factory', cache_factory_list = ('ram_cache_factory', 'distributed_ram_cache_factory',
'distributed_persistent_cache_factory') 'distributed_persistent_cache_factory')
for cache_factory in cache_factory_list: for cache_factory in cache_factory_list:
print '\n\t==> %s' % cache_factory print('\n\t==> %s' % cache_factory)
my_cache = CachingMethod(py_script_obj, my_cache = CachingMethod(py_script_obj,
'py_script_obj', 'py_script_obj',
cache_factory=cache_factory) cache_factory=cache_factory)
# First call, fill the cache # First call, fill the cache
calculation_time = self._callCache(my_cache, real_calculation=True) calculation_time = self._callCache(my_cache, real_calculation=True)
print "\n\tCalculation time (1st call)", calculation_time print("\n\tCalculation time (1st call)", calculation_time)
## 2nd call - should be cached now ## 2nd call - should be cached now
calculation_time = self._callCache(my_cache, real_calculation=False) calculation_time = self._callCache(my_cache, real_calculation=False)
print "\n\tCalculation time (2nd call)", calculation_time print("\n\tCalculation time (2nd call)", calculation_time)
# Wait expiration period then check that value is computed # Wait expiration period then check that value is computed
# .1 is an additional epsilon delay to work around time precision issues # .1 is an additional epsilon delay to work around time precision issues
time_left_to_wait = .1 + self.cache_duration time_left_to_wait = .1 + self.cache_duration
print "\n\tSleep %.2f seconds to wait expiration time" % time_left_to_wait print("\n\tSleep %.2f seconds to wait expiration time" % time_left_to_wait)
time.sleep(time_left_to_wait) time.sleep(time_left_to_wait)
# Call conversion for ram_cache_factory # Call conversion for ram_cache_factory
calculation_time = self._callCache(my_cache, real_calculation=True) calculation_time = self._callCache(my_cache, real_calculation=True)
print "\n\tCalculation time (3rd call)", calculation_time print("\n\tCalculation time (3rd call)", calculation_time)
def test_06_CheckCacheBag(self): def test_06_CheckCacheBag(self):
""" """
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
# #
############################################################################## ##############################################################################
from __future__ import print_function
import unittest import unittest
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
...@@ -131,12 +132,12 @@ class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -131,12 +132,12 @@ class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional):
match_string1 = 'data-gadget-editable="field_%s"' % field_id match_string1 = 'data-gadget-editable="field_%s"' % field_id
match_string2 = 'data-gadget-value="%s"' % html_quote(text_content) match_string2 = 'data-gadget-value="%s"' % html_quote(text_content)
if html_text.find(match_string1) == -1: if html_text.find(match_string1) == -1:
print html_text print(html_text)
print match_string1 print(match_string1)
return False return False
if html_text.find(match_string2) == -1: if html_text.find(match_string2) == -1:
print html_text print(html_text)
print match_string2 print(match_string2)
return False return False
return True return True
...@@ -156,13 +157,13 @@ class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -156,13 +157,13 @@ class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional):
match_string1 = 'data-gadget-editable="field_%s"' % field_id match_string1 = 'data-gadget-editable="field_%s"' % field_id
match_string2 = 'data-gadget-value="%s"' % html_quote(text_content) match_string2 = 'data-gadget-value="%s"' % html_quote(text_content)
if html_text.find(match_string1) == -1: if html_text.find(match_string1) == -1:
print html_text print(html_text)
print match_string1 print(match_string1)
import pdb; pdb.set_trace() import pdb; pdb.set_trace()
return False return False
if html_text.find(match_string2) == -1: if html_text.find(match_string2) == -1:
print html_text print(html_text)
print match_string2 print(match_string2)
import pdb; pdb.set_trace() import pdb; pdb.set_trace()
return False return False
return True return True
...@@ -182,12 +183,12 @@ class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -182,12 +183,12 @@ class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional):
match_string1 = "data-gadget-editable=" match_string1 = "data-gadget-editable="
match_string2 = 'data-gadget-value="%s"' % html_quote(text_content) match_string2 = 'data-gadget-value="%s"' % html_quote(text_content)
if html_text.find(match_string1) != -1: if html_text.find(match_string1) != -1:
print html_text print(html_text)
print match_string1 print(match_string1)
return False return False
if html_text.find(match_string2) == -1: if html_text.find(match_string2) == -1:
print html_text print(html_text)
print match_string2 print(match_string2)
return False return False
return True return True
......
...@@ -872,12 +872,10 @@ class TestDocument(TestDocumentMixin): ...@@ -872,12 +872,10 @@ class TestDocument(TestDocumentMixin):
self.tic() self.tic()
test_document_set = {document_1, document_2, document_3, person, web_page, organisation} test_document_set = {document_1, document_2, document_3, person, web_page, organisation}
def getAdvancedSearchTextResultList(searchable_text, portal_type=None,src__=0): def getAdvancedSearchTextResultList(searchable_text, portal_type=None):
kw = {'full_text': searchable_text} kw = {'full_text': searchable_text}
if portal_type is not None: if portal_type is not None:
kw['portal_type'] = portal_type kw['portal_type'] = portal_type
if src__==1:
print portal.portal_catalog(src__=src__,**kw)
result_list = [x.getObject() for x in portal.portal_catalog(**kw)] result_list = [x.getObject() for x in portal.portal_catalog(**kw)]
return [x for x in result_list if x in test_document_set] return [x for x in result_list if x in test_document_set]
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
# #
############################################################################## ##############################################################################
from __future__ import print_function
from test import pystone from test import pystone
from time import time from time import time
pystone.clock = time pystone.clock = time
...@@ -72,10 +73,10 @@ class TestWorkflowPerformance(TestPerformanceMixin): ...@@ -72,10 +73,10 @@ class TestWorkflowPerformance(TestPerformanceMixin):
end = time() end = time()
print "\n%s pystones/second" % pystone.pystones()[1] print("\n%s pystones/second" % pystone.pystones()[1])
message = "\n%s took %.4gs (%s foo(s))" % (self._testMethodName, message = "\n%s took %.4gs (%s foo(s))" % (self._testMethodName,
end - start, foo_count) end - start, foo_count)
print message print(message)
ZopeTestCase._print(message) ZopeTestCase._print(message)
# some checking to make sure we tested something relevant # some checking to make sure we tested something relevant
......
from __future__ import print_function
import PIL.Image as PIL_Image import PIL.Image as PIL_Image
import os import os
import transaction import transaction
...@@ -42,9 +43,9 @@ def uploadImage(self): ...@@ -42,9 +43,9 @@ def uploadImage(self):
def cleanUp(self): def cleanUp(self):
portal = self.getPortalObject() portal = self.getPortalObject()
print "exists path: %r" %os.path.exists("tmp/selenium_image_test.jpg") print("exists path: %r" %os.path.exists("tmp/selenium_image_test.jpg"))
if os.path.exists("tmp/selenium_image_test.jpg"): if os.path.exists("tmp/selenium_image_test.jpg"):
print "REMOVE IMAGE: %s" %(os.remove("tmp/selenium_image_test.jpg")) print("REMOVE IMAGE: %s" %(os.remove("tmp/selenium_image_test.jpg")))
portal.image_module.manage_delObjects(ids=['testTileTransformed']) portal.image_module.manage_delObjects(ids=['testTileTransformed'])
return True return True
else: else:
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
from __future__ import print_function
import os, sys, shutil, tempfile import os, sys, shutil, tempfile
from cStringIO import StringIO from cStringIO import StringIO
from zLOG import LOG,ERROR,INFO,WARNING from zLOG import LOG,ERROR,INFO,WARNING
...@@ -175,15 +176,15 @@ class ZoomifyBase: ...@@ -175,15 +176,15 @@ class ZoomifyBase:
lr_y = ul_y + self.tileSize lr_y = ul_y + self.tileSize
else: else:
lr_y = self.originalHeight lr_y = self.originalHeight
print "Going to open image" print("Going to open image")
imageRow = image.crop([0, ul_y, self.originalWidth, lr_y]) imageRow = image.crop([0, ul_y, self.originalWidth, lr_y])
saveFilename = root + str(tier) + '-' + str(row) + ext saveFilename = root + str(tier) + '-' + str(row) + ext
if imageRow.mode != 'RGB': if imageRow.mode != 'RGB':
imageRow = imageRow.convert('RGB') imageRow = imageRow.convert('RGB')
imageRow.save(os.path.join(tempfile.gettempdir(), saveFilename), imageRow.save(os.path.join(tempfile.gettempdir(), saveFilename),
'JPEG', quality=100) 'JPEG', quality=100)
print "os path exist : %r" % os.path.exists(os.path.join( print("os path exist : %r" % os.path.exists(os.path.join(
tempfile.gettempdir(), saveFilename)) tempfile.gettempdir(), saveFilename)))
if os.path.exists(os.path.join(tempfile.gettempdir(), saveFilename)): if os.path.exists(os.path.join(tempfile.gettempdir(), saveFilename)):
self.processRowImage(tier=tier, row=row) self.processRowImage(tier=tier, row=row)
row += 1 row += 1
...@@ -191,7 +192,7 @@ class ZoomifyBase: ...@@ -191,7 +192,7 @@ class ZoomifyBase:
def processRowImage(self, tier=0, row=0): def processRowImage(self, tier=0, row=0):
""" for an image, create and save tiles """ """ for an image, create and save tiles """
print '*** processing tier: ' + str(tier) + ' row: ' + str(row) print('*** processing tier: ' + str(tier) + ' row: ' + str(row))
tierWidth, tierHeight = self._v_scaleInfo[tier] tierWidth, tierHeight = self._v_scaleInfo[tier]
rowsForTier = tierHeight/self.tileSize rowsForTier = tierHeight/self.tileSize
if tierHeight % self.tileSize > 0: if tierHeight % self.tileSize > 0:
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
Tests invoice creation from simulation. Tests invoice creation from simulation.
""" """
from __future__ import print_function
import xml.dom.minidom import xml.dom.minidom
import zipfile import zipfile
...@@ -1273,7 +1274,7 @@ self.portal.getDefaultModule(self.packing_list_portal_type).newContent( ...@@ -1273,7 +1274,7 @@ self.portal.getDefaultModule(self.packing_list_portal_type).newContent(
def _acceptDivergenceOnInvoice(self, invoice, divergence_list): def _acceptDivergenceOnInvoice(self, invoice, divergence_list):
print invoice, divergence_list print(invoice, divergence_list)
self._solveDivergence(invoice, 'quantity', 'Accept Solver') self._solveDivergence(invoice, 'quantity', 'Accept Solver')
def test_accept_quantity_divergence_on_invoice_with_stopped_packing_list( def test_accept_quantity_divergence_on_invoice_with_stopped_packing_list(
...@@ -1326,7 +1327,7 @@ self.portal.getDefaultModule(self.packing_list_portal_type).newContent( ...@@ -1326,7 +1327,7 @@ self.portal.getDefaultModule(self.packing_list_portal_type).newContent(
self.assertEqual('solved', packing_list.getCausalityState()) self.assertEqual('solved', packing_list.getCausalityState())
def _adoptDivergenceOnInvoice(self, invoice, divergence_list): def _adoptDivergenceOnInvoice(self, invoice, divergence_list):
print invoice, divergence_list print(invoice, divergence_list)
self._solveDivergence(invoice, 'quantity', 'Adopt Solver') self._solveDivergence(invoice, 'quantity', 'Adopt Solver')
def test_adopt_quantity_divergence_on_invoice_line_with_stopped_packing_list( def test_adopt_quantity_divergence_on_invoice_line_with_stopped_packing_list(
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
# #
############################################################################## ##############################################################################
from __future__ import print_function
import subprocess import subprocess
import unittest import unittest
from test import pystone from test import pystone
...@@ -57,7 +58,7 @@ class TestSimulationPerformance(TestTradeModelLineSale): ...@@ -57,7 +58,7 @@ class TestSimulationPerformance(TestTradeModelLineSale):
self.test_01_OrderWithSimpleTaxedAndDiscountedLines() self.test_01_OrderWithSimpleTaxedAndDiscountedLines()
self.__class__._order = self['order'].getRelativeUrl() self.__class__._order = self['order'].getRelativeUrl()
self.runAlarms() self.runAlarms()
print "\n%s pystones/second" % pystone.pystones()[1] print("\n%s pystones/second" % pystone.pystones()[1])
def perf_01_invoiceSimpleOrder(self, order_count=1): def perf_01_invoiceSimpleOrder(self, order_count=1):
start = time() start = time()
...@@ -118,8 +119,8 @@ class TestSimulationPerformance(TestTradeModelLineSale): ...@@ -118,8 +119,8 @@ class TestSimulationPerformance(TestTradeModelLineSale):
self.runAlarms() self.runAlarms()
end = time() end = time()
print "\n%s took %.4gs (%s order(s))" % (self._testMethodName, print("\n%s took %.4gs (%s order(s))" % (self._testMethodName,
end - start, order_count) end - start, order_count))
def perf_02_invoiceManySimpleOrders(self): def perf_02_invoiceManySimpleOrders(self):
self.perf_01_invoiceSimpleOrder(10) self.perf_01_invoiceSimpleOrder(10)
......
...@@ -69,6 +69,7 @@ and that between Sale Packing List and Sale Invoice is M:N. ...@@ -69,6 +69,7 @@ and that between Sale Packing List and Sale Invoice is M:N.
""" """
from __future__ import print_function
import unittest import unittest
from time import time from time import time
import gc import gc
...@@ -304,8 +305,8 @@ class TestSimulationPerformance(ERP5TypeTestCase, LogInterceptor): ...@@ -304,8 +305,8 @@ class TestSimulationPerformance(ERP5TypeTestCase, LogInterceptor):
after_time = time() after_time = time()
amount_of_time = after_time - before_time amount_of_time = after_time - before_time
min_time, max_time = self._getMinMaxTime(target) min_time, max_time = self._getMinMaxTime(target)
print "\n%s took %.4f (%.4f < %.4f < %.4f)" \ print("\n%s took %.4f (%.4f < %.4f < %.4f)" \
% (target, amount_of_time, min_time, amount_of_time, max_time) % (target, amount_of_time, min_time, amount_of_time, max_time))
# Reset the target to make sure that the same target is not # Reset the target to make sure that the same target is not
# measured again. # measured again.
sequence.edit(measure_target=None) sequence.edit(measure_target=None)
...@@ -792,13 +793,13 @@ class TestSimulationPerformance(ERP5TypeTestCase, LogInterceptor): ...@@ -792,13 +793,13 @@ class TestSimulationPerformance(ERP5TypeTestCase, LogInterceptor):
if measurable: if measurable:
result = sequence.get('result') result = sequence.get('result')
if result: if result:
print '' print('')
failure_list = [] failure_list = []
for target, min_time, real_time, max_time in result: for target, min_time, real_time, max_time in result:
condition = (min_time < real_time < max_time) condition = (min_time < real_time < max_time)
print '%s%s: %.4f < %.4f < %.4f' \ print('%s%s: %.4f < %.4f < %.4f' \
% (condition and ' ' or '!', % (condition and ' ' or '!',
target, min_time, real_time, max_time) target, min_time, real_time, max_time))
if not condition: if not condition:
failure_list.append(target) failure_list.append(target)
self.assertTrue(not failure_list, self.assertTrue(not failure_list,
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
# #
############################################################################## ##############################################################################
from __future__ import print_function
from time import time from time import time
import gc import gc
import subprocess import subprocess
...@@ -219,8 +220,8 @@ class TestPerformance(TestPerformanceMixin): ...@@ -219,8 +220,8 @@ class TestPerformance(TestPerformanceMixin):
bar.Bar_viewPerformance() bar.Bar_viewPerformance()
after_view = time() after_view = time()
req_time = (after_view - before_view)/100. req_time = (after_view - before_view)/100.
print "%s time to view object form %.4f < %.4f < %.4f\n" % \ print("%s time to view object form %.4f < %.4f < %.4f\n" % \
(prefix, min_, req_time, max_) (prefix, min_, req_time, max_))
if PROFILE: if PROFILE:
self.profile(bar.Bar_viewPerformance) self.profile(bar.Bar_viewPerformance)
if DO_TEST: if DO_TEST:
...@@ -291,10 +292,10 @@ class TestPerformance(TestPerformanceMixin): ...@@ -291,10 +292,10 @@ class TestPerformance(TestPerformanceMixin):
add_value = add_result[key] add_value = add_result[key]
min_view = MIN_MODULE_VIEW + LISTBOX_COEF * i min_view = MIN_MODULE_VIEW + LISTBOX_COEF * i
max_view = MAX_MODULE_VIEW + LISTBOX_COEF * i max_view = MAX_MODULE_VIEW + LISTBOX_COEF * i
print "nb objects = %s\n\tadd = %.4f < %.4f < %.4f" %(key, MIN_OBJECT_CREATION, add_value, MAX_OBJECT_CREATION) print("nb objects = %s\n\tadd = %.4f < %.4f < %.4f" %(key, MIN_OBJECT_CREATION, add_value, MAX_OBJECT_CREATION))
print "\ttic = %.4f < %.4f < %.4f" %(MIN_TIC, tic_value, MAX_TIC) print("\ttic = %.4f < %.4f < %.4f" %(MIN_TIC, tic_value, MAX_TIC))
print "\tview = %.4f < %.4f < %.4f" %(min_view, module_value, max_view) print("\tview = %.4f < %.4f < %.4f" %(min_view, module_value, max_view))
print print()
i += 1 i += 1
# then check results # then check results
if DO_TEST: if DO_TEST:
...@@ -337,10 +338,10 @@ class TestPerformance(TestPerformanceMixin): ...@@ -337,10 +338,10 @@ class TestPerformance(TestPerformanceMixin):
after_view = time() after_view = time()
req_time = (after_view - before_view)/100. req_time = (after_view - before_view)/100.
print "time to view proxyfield form %.4f < %.4f < %.4f\n" % \ print("time to view proxyfield form %.4f < %.4f < %.4f\n" % \
( MIN_OBJECT_PROXYFIELD_VIEW, ( MIN_OBJECT_PROXYFIELD_VIEW,
req_time, req_time,
MAX_OBJECT_PROXYFIELD_VIEW ) MAX_OBJECT_PROXYFIELD_VIEW ))
if PROFILE: if PROFILE:
self.profile(foo.Foo_viewProxyField) self.profile(foo.Foo_viewProxyField)
if DO_TEST: if DO_TEST:
...@@ -368,10 +369,10 @@ class TestPerformance(TestPerformanceMixin): ...@@ -368,10 +369,10 @@ class TestPerformance(TestPerformanceMixin):
after_view = time() after_view = time()
req_time = (after_view - before_view)/100. req_time = (after_view - before_view)/100.
print "time to view object form with many lines %.4f < %.4f < %.4f\n" % \ print("time to view object form with many lines %.4f < %.4f < %.4f\n" % \
( MIN_OBJECT_MANY_LINES_VIEW, ( MIN_OBJECT_MANY_LINES_VIEW,
req_time, req_time,
MAX_OBJECT_MANY_LINES_VIEW ) MAX_OBJECT_MANY_LINES_VIEW ))
if PROFILE: if PROFILE:
self.profile(foo.Foo_viewPerformance) self.profile(foo.Foo_viewPerformance)
if DO_TEST: if DO_TEST:
...@@ -407,12 +408,12 @@ class TestPropertyPerformance(TestPerformanceMixin): ...@@ -407,12 +408,12 @@ class TestPropertyPerformance(TestPerformanceMixin):
after = time() after = time()
total_time = (after - before) / 100. total_time = (after - before) / 100.
print ("time %s.%s %.4f < %.4f < %.4f\n" % \ print(("time %s.%s %.4f < %.4f < %.4f\n" % \
( self.id(), ( self.id(),
f.__doc__ or f.__name__, f.__doc__ or f.__name__,
min_time, min_time,
total_time, total_time,
max_time )) max_time )))
if PROFILE: if PROFILE:
self.profile(f, args=(i, )) self.profile(f, args=(i, ))
if DO_TEST: if DO_TEST:
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
############################################################################## ##############################################################################
from __future__ import print_function
import unittest import unittest
from Products.ERP5Type.tests.ERP5TypeFunctionalTestCase import ERP5TypeFunctionalTestCase from Products.ERP5Type.tests.ERP5TypeFunctionalTestCase import ERP5TypeFunctionalTestCase
...@@ -86,7 +87,7 @@ class TestZeleniumCore(ERP5TypeFunctionalTestCase): ...@@ -86,7 +87,7 @@ class TestZeleniumCore(ERP5TypeFunctionalTestCase):
ERP5TypeFunctionalTestCase.afterSetUp(self) ERP5TypeFunctionalTestCase.afterSetUp(self)
self.http_root_dir = tempfile.mkdtemp() self.http_root_dir = tempfile.mkdtemp()
print "Serving files on http from %r" % self.http_root_dir print("Serving files on http from %r" % self.http_root_dir)
self.generateMonitoringInstanceTree() self.generateMonitoringInstanceTree()
self.httpd_is_alive = True self.httpd_is_alive = True
......
...@@ -419,9 +419,9 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin): ...@@ -419,9 +419,9 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin):
text_document3 = self.getTestObject() text_document3 = self.getTestObject()
text_document3_permission = getattr(text_document3, permission_key, None) text_document3_permission = getattr(text_document3, permission_key, None)
print 'text_document1_permission: %r' % (text_document1_permission, ) print('text_document1_permission: %r' % (text_document1_permission, ))
print 'text_document2_permission: %r' % (text_document2_permission, ) print('text_document2_permission: %r' % (text_document2_permission, ))
print 'text_document3_permission: %r' % (text_document3_permission, ) print('text_document3_permission: %r' % (text_document3_permission, ))
self.assertEqual(tuple(getattr(text_document3, permission_key)), self.assertEqual(tuple(getattr(text_document3, permission_key)),
('Assignee', 'Assignor', 'Auditor', 'Author')) ('Assignee', 'Assignor', 'Auditor', 'Author'))
......
...@@ -22,7 +22,7 @@ result = connection.getresponse() ...@@ -22,7 +22,7 @@ result = connection.getresponse()
path = result.getheader("X-Document-Location") path = result.getheader("X-Document-Location")
result.close() result.close()
path = '/%s' % '/'.join(path.split('/')[3:]) path = '/%s' % '/'.join(path.split('/')[3:])
print path print(path)
###################################### ######################################
# Upload chunks # Upload chunks
......
...@@ -14,7 +14,7 @@ if from_cat is not None and to_cat is not None: ...@@ -14,7 +14,7 @@ if from_cat is not None and to_cat is not None:
new_category_list += (cat,) new_category_list += (cat,)
if has_changed == 1: if has_changed == 1:
o.setCategoryList(new_category_list) o.setCategoryList(new_category_list)
print("changed category %s with %s on %s" % (str(from_cat),str(to_cat),str(o.getPath()))) print(("changed category %s with %s on %s" % (str(from_cat),str(to_cat),str(o.getPath()))))
print(" ") print(" ")
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
# user: user1 password: user1 # user: user1 password: user1
# user: user2 password: user2 # user: user2 password: user2
from __future__ import print_function
from threading import Thread from threading import Thread
from time import sleep from time import sleep
from urllib import addinfourl from urllib import addinfourl
...@@ -47,13 +48,11 @@ def main(): ...@@ -47,13 +48,11 @@ def main():
# We must provide an authentication parameter such as __ac_name # We must provide an authentication parameter such as __ac_name
url = '//user%i:user%i@localhost:9673%s?__ac_name=user%s&__ac_password=user%s' % \ url = '//user%i:user%i@localhost:9673%s?__ac_name=user%s&__ac_password=user%s' % \
(i,i,list_url[i][:-1],i,i) (i,i,list_url[i][:-1],i,i)
#print "cur thread : %i" % (len(threads))
threads += [Thread(target=checker[len(threads)].CheckUrl,kwargs={'url':url})] threads += [Thread(target=checker[len(threads)].CheckUrl,kwargs={'url':url})]
#print "cur thread : %i" % (len(threads)-1)
threads[len(threads)-1].start() threads[len(threads)-1].start()
request_number += 1 request_number += 1
i+=1 i+=1
print "thread: %i request: %i url: %s" % (i,request_number,url) print("thread: %i request: %i url: %s" % (i,request_number,url))
else: else:
for t in range(0,max_thread): for t in range(0,max_thread):
if threads[t].isAlive() == 0: if threads[t].isAlive() == 0:
...@@ -63,7 +62,7 @@ def main(): ...@@ -63,7 +62,7 @@ def main():
threads[t].start() threads[t].start()
i+=1 i+=1
request_number += 1 request_number += 1
print "thread: %i request: %i url: %s" % (i,request_number,url) print("thread: %i request: %i url: %s" % (i,request_number,url))
break break
...@@ -97,7 +96,6 @@ class URLOpener(FancyURLopener): ...@@ -97,7 +96,6 @@ class URLOpener(FancyURLopener):
user_passwd, realhost = splituser(realhost) user_passwd, realhost = splituser(realhost)
if user_passwd: if user_passwd:
selector = "%s://%s%s" % (urltype, realhost, rest) selector = "%s://%s%s" % (urltype, realhost, rest)
#print "proxy via http:", host, selector
if not host: raise IOError('http error', 'no host given') if not host: raise IOError('http error', 'no host given')
if user_passwd: if user_passwd:
import base64 import base64
...@@ -146,17 +144,17 @@ class Checker(URLOpener): ...@@ -146,17 +144,17 @@ class Checker(URLOpener):
thread.start() thread.start()
while thread.isAlive(): while thread.isAlive():
sleep(0.5) sleep(0.5)
print "Connection to %s went fine" % url print("Connection to %s went fine" % url)
except IOError as err: except IOError as err:
(errno, strerror) = err.args (errno, strerror) = err.args
print "Can't connect to %s because of I/O error(%s): %s" % (url, errno, strerror) print("Can't connect to %s because of I/O error(%s): %s" % (url, errno, strerror))
def SearchUrl(self, url=None): def SearchUrl(self, url=None):
try: try:
conn = self.open_http(url) conn = self.open_http(url)
except IOError as err: except IOError as err:
(errno, strerror) = err.args (errno, strerror) = err.args
print "Can't connect to %s because of I/O error(%s): %s" % (url, errno, strerror) print("Can't connect to %s because of I/O error(%s): %s" % (url, errno, strerror))
def raise_error(self, error_key, field): def raise_error(self, error_key, field):
......
...@@ -188,8 +188,8 @@ class TestInvalidationBug(ERP5TypeTestCase): ...@@ -188,8 +188,8 @@ class TestInvalidationBug(ERP5TypeTestCase):
module.setIdGenerator('_generatePerDayId') module.setIdGenerator('_generatePerDayId')
#module.migrateToHBTree() #module.migrateToHBTree()
self.tic() self.tic()
print 'OID(%s) = %r' % (module.getRelativeUrl(), module._p_oid) print('OID(%s) = %r' % (module.getRelativeUrl(), module._p_oid))
print ' OID(_tree) = %r' % module._tree._p_oid print(' OID(_tree) = %r' % module._tree._p_oid)
previous = DateTime() previous = DateTime()
skin_folder = self.getPortal().portal_skins.custom skin_folder = self.getPortal().portal_skins.custom
if 'create_script' in skin_folder.objectIds(): if 'create_script' in skin_folder.objectIds():
......
...@@ -103,7 +103,7 @@ class TestSecurityMixin(ERP5TypeTestCase): ...@@ -103,7 +103,7 @@ class TestSecurityMixin(ERP5TypeTestCase):
if os.environ.get('erp5_debug_mode') or '/erp5/' in filename or '<portal_components' in filename: if os.environ.get('erp5_debug_mode') or '/erp5/' in filename or '<portal_components' in filename:
error_list.append('%s:%s %s' % (filename, lineno, method_id)) error_list.append('%s:%s %s' % (filename, lineno, method_id))
else: else:
print('Ignoring missing security definition for %s in %s:%s ' % (method_id, filename, lineno)) print(('Ignoring missing security definition for %s in %s:%s ' % (method_id, filename, lineno)))
if error_list: if error_list:
message = '\nThe following %s methods have a docstring but have no security assertions.\n\t%s' \ message = '\nThe following %s methods have a docstring but have no security assertions.\n\t%s' \
% (len(error_list), '\n\t'.join(error_list)) % (len(error_list), '\n\t'.join(error_list))
......
...@@ -690,7 +690,7 @@ if validator_to_use == 'tidy': ...@@ -690,7 +690,7 @@ if validator_to_use == 'tidy':
warning = False warning = False
validator_path = '/usr/bin/tidy' validator_path = '/usr/bin/tidy'
if not os.path.exists(validator_path): if not os.path.exists(validator_path):
print 'tidy is not installed at %s' % validator_path print('tidy is not installed at %s' % validator_path)
else: else:
validator = TidyValidator(validator_path, show_warnings) validator = TidyValidator(validator_path, show_warnings)
......
...@@ -27,5 +27,5 @@ ...@@ -27,5 +27,5 @@
############################################################################## ##############################################################################
def say_hello(): def say_hello():
print 'hello' print('hello')
...@@ -454,10 +454,10 @@ class ERP5TypeFunctionalTestCase(ERP5TypeTestCase): ...@@ -454,10 +454,10 @@ class ERP5TypeFunctionalTestCase(ERP5TypeTestCase):
def _verboseErrorLog(self, size=10): def _verboseErrorLog(self, size=10):
for entry in self.portal.error_log.getLogEntries()[:size]: for entry in self.portal.error_log.getLogEntries()[:size]:
print "="*20 print("="*20)
print "ERROR ID : %s" % entry["id"] print("ERROR ID : %s" % entry["id"])
print "TRACEBACK :" print("TRACEBACK :")
print entry["tb_text"] print(entry["tb_text"])
def testFunctionalTestRunner(self): def testFunctionalTestRunner(self):
# Check the zuite page templates can be rendered, because selenium test # Check the zuite page templates can be rendered, because selenium test
......
...@@ -33,4 +33,4 @@ class TestPystone(unittest.TestCase): ...@@ -33,4 +33,4 @@ class TestPystone(unittest.TestCase):
"""Tests to get pystone value """Tests to get pystone value
""" """
def test_pystone(self): def test_pystone(self):
print "PYSTONE RESULT (time,score) : %r" % (pystone.pystones(),) print("PYSTONE RESULT (time,score) : %r" % (pystone.pystones(),))
...@@ -55,11 +55,11 @@ class TestSQLBench(unittest.TestCase): ...@@ -55,11 +55,11 @@ class TestSQLBench(unittest.TestCase):
sqlbench_path + '/test-alter-table', sqlbench_path + '/test-alter-table',
'--database', database, '--database', database,
'--host', host, '--user', user, '--password', password] '--host', host, '--user', user, '--password', password]
print command_list print(command_list)
process = subprocess.Popen(command_list, process = subprocess.Popen(command_list,
cwd = sqlbench_path, cwd = sqlbench_path,
stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = process.communicate() output, error = process.communicate()
self.assertEqual(0, len(error), error) self.assertEqual(0, len(error), error)
print output print(output)
self.assertTrue(output.find("Total time: ")>=0) self.assertTrue(output.find("Total time: ")>=0)
#!/usr/bin/env python2.7 #!/usr/bin/env python2.7
from __future__ import absolute_import from __future__ import absolute_import
from __future__ import print_function
import argparse, sys, os, textwrap import argparse, sys, os, textwrap
from erp5.util import taskdistribution from erp5.util import taskdistribution
...@@ -8,7 +9,7 @@ from erp5.util import taskdistribution ...@@ -8,7 +9,7 @@ from erp5.util import taskdistribution
from . import ERP5TypeTestSuite from . import ERP5TypeTestSuite
def _parsingErrorHandler(data, _): def _parsingErrorHandler(data, _):
print >> sys.stderr, 'Error parsing data:', repr(data) print('Error parsing data:', repr(data), file=sys.stderr)
taskdistribution.patchRPCParser(_parsingErrorHandler) taskdistribution.patchRPCParser(_parsingErrorHandler)
def makeSuite( def makeSuite(
...@@ -119,8 +120,8 @@ def main(): ...@@ -119,8 +120,8 @@ def main():
args.zserver_frontend_url_list.split(',') if args.zserver_frontend_url_list else ()) args.zserver_frontend_url_list.split(',') if args.zserver_frontend_url_list else ())
if args.zserver_address_list and len(args.zserver_address_list) < args.node_quantity: if args.zserver_address_list and len(args.zserver_address_list) < args.node_quantity:
print >> sys.stderr, 'Not enough zserver address/frontends for node quantity %s (%r)' % ( print('Not enough zserver address/frontends for node quantity %s (%r)' % (
args.node_quantity, args.zserver_address_list) args.node_quantity, args.zserver_address_list), file=sys.stderr)
sys.exit(1) sys.exit(1)
# sanity check # sanity check
......
#!/usr/bin/env python2.7 #!/usr/bin/env python2.7
from __future__ import print_function
import os import os
import sys import sys
import pdb import pdb
...@@ -698,7 +699,7 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None): ...@@ -698,7 +699,7 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None):
transaction.commit() transaction.commit()
except: except:
import traceback import traceback
print "runUnitTestList Exception : %r" % (traceback.print_exc(),) print("runUnitTestList Exception : %r" % (traceback.print_exc(),))
# finally does not expect opened transaction, even in the # finally does not expect opened transaction, even in the
# case of a Ctrl-C. # case of a Ctrl-C.
transaction.abort() transaction.abort()
...@@ -733,10 +734,10 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None): ...@@ -733,10 +734,10 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None):
def usage(stream, msg=None): def usage(stream, msg=None):
if msg: if msg:
print >>stream, msg print(msg, file=stream)
print >>stream print(file=stream)
program = os.path.basename(sys.argv[0]) program = os.path.basename(sys.argv[0])
print >>stream, __doc__ % {"program": program} print(__doc__ % {"program": program}, file=stream)
log_directory = None log_directory = None
def main(argument_list=None): def main(argument_list=None):
......
from __future__ import absolute_import from __future__ import absolute_import
from __future__ import print_function
import os import os
import logging import logging
from Products.Archetypes.tests.atsitetestcase import ATSiteTestCase from Products.Archetypes.tests.atsitetestcase import ATSiteTestCase
...@@ -44,8 +45,8 @@ class TransformTest(ATSiteTestCase): ...@@ -44,8 +45,8 @@ class TransformTest(ATSiteTestCase):
output = open(output) output = open(output)
except IOError: except IOError:
import sys import sys
print >>sys.stderr, 'No output file found.' print('No output file found.', file=sys.stderr)
print >>sys.stderr, 'File %s created, check it !' % self.output print('File %s created, check it !' % self.output, file=sys.stderr)
output = open(output, 'w') output = open(output, 'w')
output.write(got) output.write(got)
output.close() output.close()
...@@ -238,7 +239,7 @@ def make_tests(test_descr=TRANSFORMS_TESTINFO): ...@@ -238,7 +239,7 @@ def make_tests(test_descr=TRANSFORMS_TESTINFO):
continue continue
if TR_NAMES is not None and not _transform.name() in TR_NAMES: if TR_NAMES is not None and not _transform.name() in TR_NAMES:
print 'skip test for', _transform.name() print('skip test for', _transform.name())
continue continue
class TransformTestSubclass(TransformTest): class TransformTestSubclass(TransformTest):
......
...@@ -2,7 +2,7 @@ import sys ...@@ -2,7 +2,7 @@ import sys
import httplib import httplib
if ( len(sys.argv) != 5 ): if ( len(sys.argv) != 5 ):
print "usage tinyWebClient.py host port method path" print("usage tinyWebClient.py host port method path")
else: else:
host = sys.argv[1] host = sys.argv[1]
port = sys.argv[2] port = sys.argv[2]
...@@ -10,7 +10,7 @@ else: ...@@ -10,7 +10,7 @@ else:
path = sys.argv[4] path = sys.argv[4]
info = (host, port) info = (host, port)
print "%s:%s" % info print("%s:%s" % info)
conn = httplib.HTTPConnection("%s:%s" % info) conn = httplib.HTTPConnection("%s:%s" % info)
conn.request(method, path) conn.request(method, path)
print conn.getresponse().msg print(conn.getresponse().msg)
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
# serves files relative to the current directory. # serves files relative to the current directory.
# cgi-bin directory serves Python CGIs. # cgi-bin directory serves Python CGIs.
from __future__ import print_function
import BaseHTTPServer import BaseHTTPServer
import CGIHTTPServer import CGIHTTPServer
import time import time
...@@ -62,12 +63,12 @@ if __name__ == '__main__': ...@@ -62,12 +63,12 @@ if __name__ == '__main__':
server_address = ('', port) server_address = ('', port)
httpd = BaseHTTPServer.HTTPServer(server_address, HTTPHandler) httpd = BaseHTTPServer.HTTPServer(server_address, HTTPHandler)
print "serving at port", port print("serving at port", port)
print "To run the entire JsUnit test suite, open" print("To run the entire JsUnit test suite, open")
print (" http://localhost:8000/jsunit/testRunner.html?testPage=" print(" http://localhost:8000/jsunit/testRunner.html?testPage="
"http://localhost:8000/tests/JsUnitSuite.html&autoRun=true") "http://localhost:8000/tests/JsUnitSuite.html&autoRun=true")
print "To run the acceptance test suite, open" print("To run the acceptance test suite, open")
print " http://localhost:8000/TestRunner.html" print(" http://localhost:8000/TestRunner.html")
while not HTTPHandler.quitRequestReceived : while not HTTPHandler.quitRequestReceived :
httpd.handle_request() httpd.handle_request()
......
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