Commit 473b34b3 authored by Arnaud Fontaine's avatar Arnaud Fontaine

WIP: Why?

parent 246deb0a
...@@ -60,7 +60,9 @@ class TestIdToolUpgrade(ERP5TypeTestCase): ...@@ -60,7 +60,9 @@ class TestIdToolUpgrade(ERP5TypeTestCase):
self.tic() self.tic()
def beforeTearDown(self): def beforeTearDown(self):
self.portal.portal_caches.clearAllCache()
self.id_tool.clearGenerator(all=True) self.id_tool.clearGenerator(all=True)
self.tic()
Please register or sign in to reply
def createGenerators(self): def createGenerators(self):
""" """
......
...@@ -56,6 +56,7 @@ class TestXForwardedFor(ERP5TypeTestCase): ...@@ -56,6 +56,7 @@ class TestXForwardedFor(ERP5TypeTestCase):
response = requests.get( response = requests.get(
'%s/%s' % (self.portal.absolute_url(), script_id), '%s/%s' % (self.portal.absolute_url(), script_id),
headers={'X-Forwarded-For': '1.2.3.4'}, headers={'X-Forwarded-For': '1.2.3.4'},
timeout=5,
Please register or sign in to reply
) )
self.assertNotEqual(response.text, '1.2.3.4') self.assertNotEqual(response.text, '1.2.3.4')
last_line = get_Z2_log_last_line() last_line = get_Z2_log_last_line()
...@@ -63,6 +64,7 @@ class TestXForwardedFor(ERP5TypeTestCase): ...@@ -63,6 +64,7 @@ class TestXForwardedFor(ERP5TypeTestCase):
response = requests.get( response = requests.get(
'%s/%s' % (self.portal.absolute_url(), script_id), '%s/%s' % (self.portal.absolute_url(), script_id),
headers={'X-Forwarded-For': '1.2.3.4, 5.6.7.8'}, headers={'X-Forwarded-For': '1.2.3.4, 5.6.7.8'},
timeout=5,
) )
self.assertNotEqual(response.text, '1.2.3.4') self.assertNotEqual(response.text, '1.2.3.4')
self.assertNotEqual(response.text, '5.6.7.8') self.assertNotEqual(response.text, '5.6.7.8')
...@@ -71,6 +73,7 @@ class TestXForwardedFor(ERP5TypeTestCase): ...@@ -71,6 +73,7 @@ class TestXForwardedFor(ERP5TypeTestCase):
self.assertFalse(last_line.startswith('5.6.7.8 - '), last_line) self.assertFalse(last_line.startswith('5.6.7.8 - '), last_line)
response = requests.get( response = requests.get(
'%s/%s' % (self.portal.absolute_url(), script_id), '%s/%s' % (self.portal.absolute_url(), script_id),
timeout=5,
) )
self.assertNotEqual(response.text, '1.2.3.4') self.assertNotEqual(response.text, '1.2.3.4')
last_line = get_Z2_log_last_line() last_line = get_Z2_log_last_line()
...@@ -81,6 +84,7 @@ class TestXForwardedFor(ERP5TypeTestCase): ...@@ -81,6 +84,7 @@ class TestXForwardedFor(ERP5TypeTestCase):
response = requests.get( response = requests.get(
'%s/%s' % (self.portal.absolute_url(), script_id), '%s/%s' % (self.portal.absolute_url(), script_id),
headers={'X-Forwarded-For': '1.2.3.4'}, headers={'X-Forwarded-For': '1.2.3.4'},
timeout=5,
) )
self.assertEqual(response.text, '1.2.3.4') self.assertEqual(response.text, '1.2.3.4')
last_line = get_Z2_log_last_line() last_line = get_Z2_log_last_line()
...@@ -88,12 +92,14 @@ class TestXForwardedFor(ERP5TypeTestCase): ...@@ -88,12 +92,14 @@ class TestXForwardedFor(ERP5TypeTestCase):
response = requests.get( response = requests.get(
'%s/%s' % (self.portal.absolute_url(), script_id), '%s/%s' % (self.portal.absolute_url(), script_id),
headers={'X-Forwarded-For': '1.2.3.4, 5.6.7.8'}, headers={'X-Forwarded-For': '1.2.3.4, 5.6.7.8'},
timeout=5,
) )
self.assertEqual(response.text, '1.2.3.4') self.assertEqual(response.text, '1.2.3.4')
last_line = get_Z2_log_last_line() last_line = get_Z2_log_last_line()
self.assertTrue(last_line.startswith('1.2.3.4 - '), last_line) self.assertTrue(last_line.startswith('1.2.3.4 - '), last_line)
response = requests.get( response = requests.get(
'%s/%s' % (self.portal.absolute_url(), script_id), '%s/%s' % (self.portal.absolute_url(), script_id),
timeout=5,
) )
self.assertNotEqual(response.text, '1.2.3.4') self.assertNotEqual(response.text, '1.2.3.4')
last_line = get_Z2_log_last_line() last_line = get_Z2_log_last_line()
......
...@@ -3,6 +3,8 @@ text = context.asText() ...@@ -3,6 +3,8 @@ text = context.asText()
LENGTH = 25 LENGTH = 25
# TODO: Think about the display length of multibyte characters. # TODO: Think about the display length of multibyte characters.
if six.PY3:
return text[:LENGTH]
  • this is because on py3 we have str so we don't need to worry that we cut in the middle of multibyte character

    python3

    >>> print("héhé"[:2])
    hé

    python2

    >>> print("héhé"[:2])
    h

    because

    >>> print(repr("héhé"))
    'h\xc3\xa9h\xc3\xa9'
    >>> print(repr("héhé"[:2]))
    'h\xc3'
  • Thanks!

Please register or sign in to reply
try: try:
return six.text_type(text, 'utf-8')[:LENGTH].encode('utf-8') return six.text_type(text, 'utf-8')[:LENGTH].encode('utf-8')
except UnicodeDecodeError: except UnicodeDecodeError:
......
...@@ -231,6 +231,7 @@ class TestDocument(TestDocumentMixin): ...@@ -231,6 +231,7 @@ class TestDocument(TestDocumentMixin):
image_size = image.size image_size = image.size
except ImportError: except ImportError:
identify_output = Popen(['identify', filename], identify_output = Popen(['identify', filename],
universal_newlines=True,
Please register or sign in to reply
stdout=PIPE).communicate()[0] stdout=PIPE).communicate()[0]
image_size = tuple([int(x) for x in identify_output.split()[2].split('x')]) image_size = tuple([int(x) for x in identify_output.split()[2].split('x')])
os.remove(filename) os.remove(filename)
......
...@@ -1656,6 +1656,10 @@ return True ...@@ -1656,6 +1656,10 @@ return True
document_object.getId()) document_object.getId())
response_a = self.publish(path) response_a = self.publish(path)
action.setVisible(0) action.setVisible(0)
def cleanup():
action.setVisible(1)
self.tic()
self.addCleanup(cleanup)
Please register or sign in to reply
self.tic() self.tic()
response_b = self.publish(path) response_b = self.publish(path)
self.assertNotEqual(response_a.getBody(), response_b.getBody()) self.assertNotEqual(response_a.getBody(), response_b.getBody())
...@@ -1726,6 +1730,7 @@ return True ...@@ -1726,6 +1730,7 @@ return True
response = requests.get( response = requests.get(
self.portal.absolute_url(), self.portal.absolute_url(),
cookies=auth_cookie, cookies=auth_cookie,
timeout=10,
) )
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers['Cache-Control'], 'private') self.assertEqual(response.headers['Cache-Control'], 'private')
...@@ -1734,6 +1739,7 @@ return True ...@@ -1734,6 +1739,7 @@ return True
response = requests.get( response = requests.get(
'%s/%s' % (website.absolute_url(), 'released_page'), '%s/%s' % (website.absolute_url(), 'released_page'),
cookies=auth_cookie, cookies=auth_cookie,
timeout=10,
) )
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers['Cache-Control'], 'max-age=0, no-store') self.assertEqual(response.headers['Cache-Control'], 'max-age=0, no-store')
...@@ -1742,6 +1748,7 @@ return True ...@@ -1742,6 +1748,7 @@ return True
response = requests.get( response = requests.get(
'%s/%s?format=txt' % (website.absolute_url(), 'released_page'), '%s/%s?format=txt' % (website.absolute_url(), 'released_page'),
cookies=auth_cookie, cookies=auth_cookie,
timeout=10,
) )
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers['Cache-Control'], 'max-age=0, no-store') self.assertEqual(response.headers['Cache-Control'], 'max-age=0, no-store')
...@@ -1749,12 +1756,14 @@ return True ...@@ -1749,12 +1756,14 @@ return True
# published page # published page
response = requests.get( response = requests.get(
'%s/%s' % (website.absolute_url(), 'published_page'), '%s/%s' % (website.absolute_url(), 'published_page'),
timeout=10,
) )
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers['Cache-Control'], 'max-age=600, stale-while-revalidate=360000, public') self.assertEqual(response.headers['Cache-Control'], 'max-age=600, stale-while-revalidate=360000, public')
response = requests.get( response = requests.get(
'%s/%s' % (website.absolute_url(), 'published_page'), '%s/%s' % (website.absolute_url(), 'published_page'),
cookies=auth_cookie, cookies=auth_cookie,
timeout=10,
) )
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers['Cache-Control'], 'max-age=0, no-store') self.assertEqual(response.headers['Cache-Control'], 'max-age=0, no-store')
...@@ -1762,12 +1771,14 @@ return True ...@@ -1762,12 +1771,14 @@ return True
# converted published page # converted published page
response = requests.get( response = requests.get(
'%s/%s?format=txt' % (website.absolute_url(), 'published_page'), '%s/%s?format=txt' % (website.absolute_url(), 'published_page'),
timeout=10,
) )
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers['Cache-Control'], 'max-age=600, stale-while-revalidate=360000, public') self.assertEqual(response.headers['Cache-Control'], 'max-age=600, stale-while-revalidate=360000, public')
response = requests.get( response = requests.get(
'%s/%s?format=txt' % (website.absolute_url(), 'published_page'), '%s/%s?format=txt' % (website.absolute_url(), 'published_page'),
cookies=auth_cookie, cookies=auth_cookie,
timeout=10,
) )
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers['Cache-Control'], 'max-age=600, stale-while-revalidate=360000, public') self.assertEqual(response.headers['Cache-Control'], 'max-age=600, stale-while-revalidate=360000, public')
......
...@@ -84,11 +84,12 @@ class TestWebDavSupport(ERP5TypeTestCase): ...@@ -84,11 +84,12 @@ class TestWebDavSupport(ERP5TypeTestCase):
person = self.portal.person_module.newContent() person = self.portal.person_module.newContent()
self.tic() self.tic()
file_object = self.makeFileUpload('images/erp5_logo.png') file_object = self.makeFileUpload('images/erp5_logo.png')
response = self.publish(person.getPath() + '/erp5_logo.png', response = self.publish(
request_method='PUT', person.getPath() + '/erp5_logo.png',
stdin=file_object, request_method='PUT',
basic=self.authentication) stdin=file_object,
self.assertEqual(response.getStatus(), httplib.CREATED) env={"CONTENT_TYPE": 'image/png'},
  • with zope5 (I don't know exactly since what), the content type header seems to be needed for webdav ( RFC says "should" https://datatracker.ietf.org/doc/html/rfc4918#section-9.7.1 but here it's "must" ). Because we don't use webdav so much it seems no problem.

  • I checked in Zope source code but I could see any place where this is a "must"...

  • I wrote this from memory, but maybe I did not even check zope code. I feel this is "good enough" to commit this without too much details because webdav is not critical

  • I investigated a bit. It seems to be that since the following Zope.git commit, a missing CONTENT_TYPE means application/x-www-form-urlencoded (whereas the previous implementation using cgi.FieldStorage was considering this as text/plain):

    commit 5b324f6c461f5ea1cc069739b6c32a1a5ff59df9
    Author: Dieter Maurer <d-maurer@users.noreply.github.com>
    Date:   Thu Jan 19 07:15:18 2023 +0100
    
        replace `cgi.FieldStorage` by `multipart` (#1094)
        
        * replace `cgi.FieldStorage` by `multipart`
        * interpret a missing `CONTENT_TYPE` as `application/x-www-form-urlencoded` (required by some tests

    And the backtrace FTR:

    Traceback (most recent call last):
      File "erp5://portal_components/test.erp5.testWebDavSupport", line 232, in test_PROPFIND_on_document
        response = self.publish(
      File "/opt/slapgrid/3f9add9291086dee302fc478df4b3130/parts/erp5/product/ERP5Type/tests/ERP5TypeTestCase.py", line 793, in publish
        return super(ERP5TypeTestCaseMixin, self).publish(
      File "/opt/slapgrid/3f9add9291086dee302fc478df4b3130/eggs/Zope-5.10-py3.9.egg/Testing/ZopeTestCase/functional.py", line 42, in wrapped_func
        return func(*args, **kw)
      File "/opt/slapgrid/3f9add9291086dee302fc478df4b3130/eggs/Zope-5.10-py3.9.egg/Testing/ZopeTestCase/functional.py", line 133, in publish
        wsgi_result = publish(env, start_response)
      File "/opt/slapgrid/3f9add9291086dee302fc478df4b3130/eggs/Zope-5.10-py3.9.egg/ZPublisher/httpexceptions.py", line 30, in __call__
        return self.application(environ, start_response)
      File "/opt/slapgrid/3f9add9291086dee302fc478df4b3130/eggs/Zope-5.10-py3.9.egg/ZPublisher/WSGIPublisher.py", line 391, in publish_module
        response = _publish(request, new_mod_info)
      File "/opt/slapgrid/3f9add9291086dee302fc478df4b3130/parts/erp5/product/ERP5Type/patches/WSGIPublisher.py", line 150, in publish
        return _original_publish(request, module_info)
      File "/opt/slapgrid/3f9add9291086dee302fc478df4b3130/eggs/Zope-5.10-py3.9.egg/ZPublisher/WSGIPublisher.py", line 251, in publish
        request.processInputs()
      File "/opt/slapgrid/3f9add9291086dee302fc478df4b3130/parts/erp5/product/Localizer/patches.py", line 37, in new_processInputs
        HTTPRequest.old_processInputs(self)
      File "/opt/slapgrid/3f9add9291086dee302fc478df4b3130/eggs/Zope-5.10-py3.9.egg/ZPublisher/HTTPRequest.py", line 544, in processInputs
        key = item.name.encode("latin-1").decode(
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe3 in position 10: invalid continuation byte
    Edited by Arnaud Fontaine
  • Thanks a lot. I agree that if tests pass without this, then no reason to have the change

  • Sorry, I didn't check carefully enough and it raises an error (see my edited comment above).

  • So it was working by chance before... I will apply this commit separately to keep a track of my investigation.

  • ah yes, I remember vaguely now. It's good to have the investigation in commit message yes

Please register or sign in to reply
basic=self.authentication)
self.assertEqual(response.getStatus(), six.moves.http_client.CREATED) self.assertEqual(response.getStatus(), six.moves.http_client.CREATED)
image = person['erp5_logo.png'] image = person['erp5_logo.png']
self.assertEqual(image.getPortalType(), 'Embedded File') self.assertEqual(image.getPortalType(), 'Embedded File')
...@@ -104,10 +105,12 @@ class TestWebDavSupport(ERP5TypeTestCase): ...@@ -104,10 +105,12 @@ class TestWebDavSupport(ERP5TypeTestCase):
path = self.portal.portal_contributions.getPath() path = self.portal.portal_contributions.getPath()
filename = 'P-DMS-Presentation.3.Pages-001-en.odp' filename = 'P-DMS-Presentation.3.Pages-001-en.odp'
file_object = self.makeFileUpload(filename) file_object = self.makeFileUpload(filename)
response = self.publish('%s/%s' % (path, filename), response = self.publish(
request_method='PUT', '%s/%s' % (path, filename),
stdin=file_object, request_method='PUT',
basic=self.authentication) stdin=file_object,
env={"CONTENT_TYPE": 'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication)
self.assertEqual(response.getStatus(), six.moves.http_client.CREATED) self.assertEqual(response.getStatus(), six.moves.http_client.CREATED)
document_module = self.getDocumentModule() document_module = self.getDocumentModule()
...@@ -126,10 +129,12 @@ class TestWebDavSupport(ERP5TypeTestCase): ...@@ -126,10 +129,12 @@ class TestWebDavSupport(ERP5TypeTestCase):
path = self.portal.portal_contributions.getPath() path = self.portal.portal_contributions.getPath()
filename = 'P-DMS-Presentation.3.Pages-001-en.odp' filename = 'P-DMS-Presentation.3.Pages-001-en.odp'
file_object = self.makeFileUpload(filename) file_object = self.makeFileUpload(filename)
response = self.publish('%s/%s' % (path, filename), response = self.publish(
request_method='PUT', '%s/%s' % (path, filename),
stdin=file_object, request_method='PUT',
basic=self.authentication) stdin=file_object,
env={"CONTENT_TYPE": 'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication)
self.assertEqual(response.getStatus(), six.moves.http_client.CREATED) self.assertEqual(response.getStatus(), six.moves.http_client.CREATED)
self.tic() self.tic()
...@@ -198,10 +203,12 @@ class TestWebDavSupport(ERP5TypeTestCase): ...@@ -198,10 +203,12 @@ class TestWebDavSupport(ERP5TypeTestCase):
path = self.portal.portal_contributions.getPath() path = self.portal.portal_contributions.getPath()
filename = 'P-DMS-Presentation.3.Pages-001-en.odp' filename = 'P-DMS-Presentation.3.Pages-001-en.odp'
file_object = self.makeFileUpload(filename) file_object = self.makeFileUpload(filename)
response = self.publish('%s/%s' % (path, filename), response = self.publish(
request_method='PUT', '%s/%s' % (path, filename),
stdin=file_object, request_method='PUT',
basic=self.authentication) stdin=file_object,
env={"CONTENT_TYPE": 'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication)
# Convert to base format and run conversion into utf-8 # Convert to base format and run conversion into utf-8
self.tic() self.tic()
...@@ -225,10 +232,12 @@ class TestWebDavSupport(ERP5TypeTestCase): ...@@ -225,10 +232,12 @@ class TestWebDavSupport(ERP5TypeTestCase):
path = self.portal.portal_contributions.getPath() path = self.portal.portal_contributions.getPath()
filename = 'P-DMS-Presentation.3.Pages-001-en.odp' filename = 'P-DMS-Presentation.3.Pages-001-en.odp'
file_object = self.makeFileUpload(filename) file_object = self.makeFileUpload(filename)
response = self.publish('%s/%s' % (path, filename), response = self.publish(
request_method='PUT', '%s/%s' % (path, filename),
stdin=file_object, request_method='PUT',
basic=self.authentication) stdin=file_object,
env={"CONTENT_TYPE": 'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication)
document_module = self.getDocumentModule() document_module = self.getDocumentModule()
document = document_module[filename] document = document_module[filename]
...@@ -263,10 +272,12 @@ class TestWebDavSupport(ERP5TypeTestCase): ...@@ -263,10 +272,12 @@ class TestWebDavSupport(ERP5TypeTestCase):
path = self.portal.portal_contributions.getPath() path = self.portal.portal_contributions.getPath()
filename = 'P-DMS-Presentation.3.Pages-001-en.odp' filename = 'P-DMS-Presentation.3.Pages-001-en.odp'
file_object = self.makeFileUpload(filename) file_object = self.makeFileUpload(filename)
response = self.publish('%s/%s' % (path, filename), response = self.publish(
request_method='PUT', '%s/%s' % (path, filename),
stdin=file_object, request_method='PUT',
basic=self.authentication) stdin=file_object,
env={"CONTENT_TYPE": 'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication)
document_module = self.getDocumentModule() document_module = self.getDocumentModule()
document = document_module[filename] document = document_module[filename]
......
...@@ -64,6 +64,7 @@ class Git(WorkingCopy): ...@@ -64,6 +64,7 @@ class Git(WorkingCopy):
def _git(self, *args, **kw): def _git(self, *args, **kw):
kw.setdefault('cwd', self.working_copy) kw.setdefault('cwd', self.working_copy)
kw.setdefault('universal_newlines', True)
argv = ['git'] argv = ['git']
try: try:
return subprocess.Popen(argv + list(args), **kw) return subprocess.Popen(argv + list(args), **kw)
...@@ -362,7 +363,6 @@ class Git(WorkingCopy): ...@@ -362,7 +363,6 @@ class Git(WorkingCopy):
raise raise
# try to update our working copy # try to update our working copy
# TODO: find a solution if there are other local changes # TODO: find a solution if there are other local changes
# TODO: solve conflicts on */bt/revision automatically
Please register or sign in to reply
try: try:
self.git(merge, '@{u}', env=env) self.git(merge, '@{u}', env=env)
except GitError as e2: except GitError as e2:
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
############################################################################## ##############################################################################
import json import json
from six.moves import urllib
from io import BytesIO from io import BytesIO
from six.moves.urllib.parse import parse_qs from six.moves.urllib.parse import parse_qs
...@@ -461,8 +460,8 @@ class TestStripePaymentSession(ERP5TypeTestCase): ...@@ -461,8 +460,8 @@ class TestStripePaymentSession(ERP5TypeTestCase):
) )
ret = self.publish( ret = self.publish(
"%s/ERP5Site_receiveStripeWebHook" % self.portal.getPath(), "%s/ERP5Site_receiveStripeWebHook" % self.portal.getPath(),
stdin=BytesIO(urllib.parse.urlencode({ stdin=BytesIO(
"BODY": json.dumps({ json.dumps({
  • If I remember correctly, this fake request was wrong, but on python2 it was equivalent

  • This is similar to "publish() stdin is now BytesIO rather than StringIO." from d8a59d7d , I believe we can put this part in the same commit

  • Thanks!

Please register or sign in to reply
"url": "https://stripe.url", "url": "https://stripe.url",
"id": "evt_%s" % "abc321_expired", "id": "evt_%s" % "abc321_expired",
"object": "event", "object": "event",
...@@ -474,9 +473,10 @@ class TestStripePaymentSession(ERP5TypeTestCase): ...@@ -474,9 +473,10 @@ class TestStripePaymentSession(ERP5TypeTestCase):
"object": "checkout.session" "object": "checkout.session"
} }
} }
}) }).encode()
}).encode()), ),
request_method="POST", request_method="POST",
env={'CONTENT_TYPE': 'application/json'},
handle_errors=False) handle_errors=False)
self.assertEqual(200, ret.getStatus()) self.assertEqual(200, ret.getStatus())
self.tic() self.tic()
...@@ -658,8 +658,8 @@ class TestStripePaymentSession(ERP5TypeTestCase): ...@@ -658,8 +658,8 @@ class TestStripePaymentSession(ERP5TypeTestCase):
) )
ret = self.publish( ret = self.publish(
"%s/ERP5Site_receiveStripeWebHook" % self.portal.getPath(), "%s/ERP5Site_receiveStripeWebHook" % self.portal.getPath(),
stdin=BytesIO(urllib.parse.urlencode({ stdin=BytesIO(
"BODY": json.dumps({ json.dumps({
"id": "evt_%s" % session_id, "id": "evt_%s" % session_id,
"object": "event", "object": "event",
"data": { "data": {
...@@ -670,9 +670,10 @@ class TestStripePaymentSession(ERP5TypeTestCase): ...@@ -670,9 +670,10 @@ class TestStripePaymentSession(ERP5TypeTestCase):
"object": "checkout.session" "object": "checkout.session"
} }
} }
}) }).encode(),
}).encode()), ),
request_method="POST", request_method="POST",
env={'CONTENT_TYPE': 'application/json'},
handle_errors=False) handle_errors=False)
self.assertEqual(200, ret.getStatus()) self.assertEqual(200, ret.getStatus())
self.tic() self.tic()
......
...@@ -41,4 +41,4 @@ def setupDummyMailHost(self): ...@@ -41,4 +41,4 @@ def setupDummyMailHost(self):
cls.__bases__ = (DummyMailHostMixin,) + cls.__bases__ cls.__bases__ = (DummyMailHostMixin,) + cls.__bases__
pmc_init_of(cls) pmc_init_of(cls)
mailhost.reset() mailhost.reset()
return True return "True" # TODO: zope4py3 Zope does not seem to publish `True` correctly
  • I wrote this TODO long time ago, I think we don't care about this TODO comment. On python2, whatever is returned by a published method of script is passed to str(), but not on python3, responses must be strings or bytes and while strictly speaking a bit incompatible, this seems better this way

Please register or sign in to reply
...@@ -1334,6 +1334,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -1334,6 +1334,7 @@ Hé Hé Hé!""", page.asText().strip())
conditional_get_response = requests.get( conditional_get_response = requests.get(
web_section.absolute_url(), web_section.absolute_url(),
headers={'If-Modified-Since': DateTime().utcdatetime().strftime('%a, %d %b %Y %H:%M:%S UTC')}, headers={'If-Modified-Since': DateTime().utcdatetime().strftime('%a, %d %b %Y %H:%M:%S UTC')},
timeout=5,
) )
self.assertEqual(conditional_get_response.status_code, 304) self.assertEqual(conditional_get_response.status_code, 304)
self.assertIn('Cache-Control', conditional_get_response.headers) self.assertIn('Cache-Control', conditional_get_response.headers)
......
...@@ -86,6 +86,7 @@ class TestOOoImportMixin(ERP5TypeTestCase): ...@@ -86,6 +86,7 @@ class TestOOoImportMixin(ERP5TypeTestCase):
self.portal.portal_categories.gender, self.portal.portal_categories.gender,
self.portal.portal_categories.region, self.portal.portal_categories.region,
]: ]:
parent.setLastId('0')
Please register or sign in to reply
parent.deleteContent(list(parent.objectIds())) parent.deleteContent(list(parent.objectIds()))
self.tic() self.tic()
......
...@@ -33,6 +33,8 @@ from Products.ZMySQLDA.DA import Connection as ZMySQLDA_Connection ...@@ -33,6 +33,8 @@ from Products.ZMySQLDA.DA import Connection as ZMySQLDA_Connection
from zope.globalrequest import getRequest from zope.globalrequest import getRequest
from zope.globalrequest import setRequest from zope.globalrequest import setRequest
import six import six
if six.PY3:
StandardError = Exception
  • maybe to fix a pyint warning

  • Thanks. I removed this bit because StandardError is not referenced at all in that file and not imported from somewhere else neither.

  • ah yes it seems this is no longer needed now that we pushed 87f6c14c to master

Please register or sign in to reply
from zope.component.hooks import setSite from zope.component.hooks import setSite
......
...@@ -22,7 +22,14 @@ from Products.PortalTransforms.transforms.broken import BrokenTransform ...@@ -22,7 +22,14 @@ from Products.PortalTransforms.transforms.broken import BrokenTransform
def import_from_name(module_name): def import_from_name(module_name):
""" import and return a module by its name """ """ import and return a module by its name """
return import_module(module_name) __traceback_info__ = (module_name,)
m = import_module(module_name)
try:
for sub in module_name.split(".")[1:]:
m = getattr(m, sub)
except AttributeError as e:
raise ImportError(str(e))
return m
  • why ? ... maybe to have a better traceback during debugging.

  • Strange... I did remove that code in dab26b0d (first by using __import__() and then import_module() in a later commit). Anyhow, this is not related to python3.

Please register or sign in to reply
def make_config_persistent(kwargs): def make_config_persistent(kwargs):
""" iterates on the given dictionnary and replace list by persistent list, """ iterates on the given dictionnary and replace list by persistent list,
......
...@@ -266,12 +266,10 @@ class TestSQLCatalog(ERP5TypeTestCase): ...@@ -266,12 +266,10 @@ class TestSQLCatalog(ERP5TypeTestCase):
self.assertRaises(exception, self._catalog, src__=1, query_table='foo', **kw) self.assertRaises(exception, self._catalog, src__=1, query_table='foo', **kw)
def catalog(self, reference_tree, kw, check_search_text=True, def catalog(self, reference_tree, kw, check_search_text=True,
check_select_expression=True, expected_failure=False): check_select_expression=True):
reference_param_dict = self._catalog.buildSQLQuery(query_table='foo', **kw) reference_param_dict = self._catalog.buildSQLQuery(query_table='foo', **kw)
query = self._catalog.buildEntireQuery(kw).query query = self._catalog.buildEntireQuery(kw).query
assertEqual = self.assertEqual assertEqual = self.assertEqual
if expected_failure:
assertEqual = unittest.expectedFailure(assertEqual)
  • expected failure work differently on python3, only the test method can be marked expected failure

  • I remember we had to change other tests because of this

  • Thanks! I put all these changes in the py2/py3: Make Products code compatible with both python2 and python3. and added a line in the commit message about this.

  • that's good

Please register or sign in to reply
assertEqual(reference_tree, query) assertEqual(reference_tree, query)
search_text = query.asSearchTextExpression(self._catalog) search_text = query.asSearchTextExpression(self._catalog)
......
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