plone / plone.i18n

Text normalization logic and language, country, cctld data.
8 stars 11 forks source link

Tests: call self.publish with handle_errors=False. #41

Closed mauritsvanrees closed 2 years ago

mauritsvanrees commented 2 years ago

This gives us a proper error message instead of a status 500. Then we can see that on ES6 there is a problem finding icons.tag('arrow-bar-right'). I think I have a fix in CMFPlone for that. Sample exception, if you want the full one:

Error in test testAcceptedLanguages (plone.i18n.tests.test_negotiation.TestCcTLDLanguageNegotiation)
Traceback (most recent call last):
  File "/Users/maurits/.pyenv/versions/3.8.12/lib/python3.8/unittest/case.py", line 60, in testPartExecutor
    yield
  File "/Users/maurits/.pyenv/versions/3.8.12/lib/python3.8/unittest/case.py", line 676, in run
    self._callTestMethod(testMethod)
  File "/Users/maurits/.pyenv/versions/3.8.12/lib/python3.8/unittest/case.py", line 633, in _callTestMethod
    method()
  File "/Users/maurits/community/plone-coredev/es6/src/plone.i18n/plone/i18n/tests/test_negotiation.py", line 266, in testAcceptedLanguages
    response = self.publish(
  File "/Users/maurits/community/plone-coredev/es6/src/Zope/src/Testing/ZopeTestCase/functional.py", line 41, in wrapped_func
    return func(*args, **kw)
  File "/Users/maurits/community/plone-coredev/es6/src/Zope/src/Testing/ZopeTestCase/functional.py", line 127, in publish
    wsgi_result = publish(env, start_response)
  File "/Users/maurits/community/plone-coredev/es6/src/Zope/src/ZPublisher/WSGIPublisher.py", line 376, in publish_module
    response = _publish(request, new_mod_info)
  File "/Users/maurits/community/plone-coredev/es6/src/Zope/src/ZPublisher/WSGIPublisher.py", line 271, in publish
    result = mapply(obj,
  File "/Users/maurits/community/plone-coredev/es6/src/Zope/src/ZPublisher/mapply.py", line 85, in mapply
    return debug(object, args, context)
  File "/Users/maurits/community/plone-coredev/es6/src/Zope/src/ZPublisher/WSGIPublisher.py", line 68, in call_object
    return obj(*args)
  File "/Users/maurits/shared-eggs/cp38/zope.browserpage-4.4.0-py3.8.egg/zope/browserpage/simpleviewclass.py", line 41, in __call__
    return self.index(*args, **kw)
  File "/Users/maurits/community/plone-coredev/es6/src/Zope/src/Products/Five/browser/pagetemplatefile.py", line 126, in __call__
    return self.__func__(__self__, *args, **kw)
  File "/Users/maurits/community/plone-coredev/es6/src/Zope/src/Products/Five/browser/pagetemplatefile.py", line 58, in __call__
    s = self.pt_render(
  File "/Users/maurits/shared-eggs/cp38/zope.pagetemplate-4.6.0-py3.8.egg/zope/pagetemplate/pagetemplate.py", line 133, in pt_render
    return self._v_program(
  File "/Users/maurits/community/plone-coredev/es6/src/Zope/src/Products/PageTemplates/engine.py", line 365, in __call__
    return template.render(**kwargs)
  File "/Users/maurits/shared-eggs/cp38/z3c.pt-3.3.1-py3.8.egg/z3c/pt/pagetemplate.py", line 176, in render
    return base_renderer(**context)
  File "/Users/maurits/shared-eggs/cp38/Chameleon-3.9.1-py3.8.egg/chameleon/zpt/template.py", line 302, in render
    return super(PageTemplate, self).render(**_kw)
  File "/Users/maurits/shared-eggs/cp38/Chameleon-3.9.1-py3.8.egg/chameleon/template.py", line 192, in render
    self._render(stream, econtext, rcontext)
  File "/Users/maurits/community/plone-coredev/es6/var/cache/f8d46c10cfff1026ac9bdab31abe8567.py", line 319, in render
    __m(__stream, econtext.copy(), rcontext, __i18n_domain)
  File "/Users/maurits/community/plone-coredev/es6/var/cache/f910c63ed8645a1ecc0243ffdd2a3528.py", line 688, in render_master
    __cache_4527708048 = _static_4480221776('provider', 'plone.toolbar', econtext=econtext)(_static_4480221584(econtext, __zt_tmp))
  File "/Users/maurits/shared-eggs/cp38/zope.contentprovider-4.2.1-py3.8.egg/zope/contentprovider/tales.py", line 79, in __call__
    return provider.render()
  File "/Users/maurits/community/plone-coredev/es6/src/plone.app.layout/plone/app/layout/viewlets/toolbar.py", line 19, in render
    return self.custom_template()
  File "/Users/maurits/community/plone-coredev/es6/src/Zope/src/Products/Five/browser/pagetemplatefile.py", line 126, in __call__
    return self.__func__(__self__, *args, **kw)
  File "/Users/maurits/community/plone-coredev/es6/src/Zope/src/Products/Five/browser/pagetemplatefile.py", line 58, in __call__
    s = self.pt_render(
  File "/Users/maurits/shared-eggs/cp38/zope.pagetemplate-4.6.0-py3.8.egg/zope/pagetemplate/pagetemplate.py", line 133, in pt_render
    return self._v_program(
  File "/Users/maurits/community/plone-coredev/es6/src/Zope/src/Products/PageTemplates/engine.py", line 365, in __call__
    return template.render(**kwargs)
  File "/Users/maurits/shared-eggs/cp38/z3c.pt-3.3.1-py3.8.egg/z3c/pt/pagetemplate.py", line 176, in render
    return base_renderer(**context)
  File "/Users/maurits/shared-eggs/cp38/Chameleon-3.9.1-py3.8.egg/chameleon/zpt/template.py", line 302, in render
    return super(PageTemplate, self).render(**_kw)
  File "/Users/maurits/shared-eggs/cp38/Chameleon-3.9.1-py3.8.egg/chameleon/template.py", line 215, in render
    raise_with_traceback(exc, tb)
  File "/Users/maurits/shared-eggs/cp38/Chameleon-3.9.1-py3.8.egg/chameleon/utils.py", line 53, in raise_with_traceback
    raise exc
  File "/Users/maurits/shared-eggs/cp38/Chameleon-3.9.1-py3.8.egg/chameleon/template.py", line 192, in render
    self._render(stream, econtext, rcontext)
  File "/Users/maurits/community/plone-coredev/es6/var/cache/424bb3a8dbef99a970cb59e9340790a7.py", line 224, in render
    __cache_4533863904 = _static_4480221776('python', "icons.tag('arrow-bar-right')", econtext=econtext)(_static_4480221584(econtext, __zt_tmp))
  File "/Users/maurits/shared-eggs/cp38/zope.tales-5.1-py3.8.egg/zope/tales/pythonexpr.py", line 73, in __call__
    return eval(self._code, vars)
   - __traceback_info__: (icons.tag('arrow-bar-right'))
  File "<string>", line 1, in <module>
  File "/Users/maurits/community/plone-coredev/es6/src/Products.CMFPlone/Products/CMFPlone/browser/icons.py", line 113, in tag
    iconfile = self._iconfile(icon)
  File "/Users/maurits/community/plone-coredev/es6/src/Products.CMFPlone/Products/CMFPlone/browser/icons.py", line 82, in _iconfile
    return site.restrictedTraverse(icon)
  File "/Users/maurits/community/plone-coredev/es6/src/Zope/src/OFS/Traversable.py", line 364, in restrictedTraverse
    return self.unrestrictedTraverse(path, default, restricted=True)
  File "/Users/maurits/community/plone-coredev/es6/src/Zope/src/OFS/Traversable.py", line 236, in unrestrictedTraverse
    next = namespaceLookup(
   - __traceback_info__: (['arrow-bar-right.svg'], '++plone++bootstrap-icons')
  File "/Users/maurits/shared-eggs/cp38/zope.traversing-4.4.1-py3.8.egg/zope/traversing/namespace.py", line 165, in namespaceLookup
    return traverser.traverse(name, ())
  File "/Users/maurits/community/plone-coredev/es6/src/Products.CMFPlone/Products/CMFPlone/traversal.py", line 36, in traverse
    resource_name, resource_filepath = resource_path.split('/', 1)
ValueError: not enough values to unpack (expected 2, got 1)

 - Expression: "python:icons.tag('arrow-bar-right')"
 - Filename:   ... rc/plone.app.layout/plone/app/layout/viewlets/toolbar.pt
 - Location:   (line 13: col 39)
 - Source:     ... lace="structure python:icons.tag('arrow-bar-right')" />
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 - Expression: "provider:plone.toolbar"
 - Filename:   ... one/Products/CMFPlone/browser/templates/main_template.pt
 - Location:   (line 55: col 32)
 - Source:     ... al:replace="structure provider:plone.toolbar" />
                                         ^^^^^^^^^^^^^^^^^^^^^^
 - Expression: "context/@@main_template/macros/master"
 - Filename:   ... pes/plone/app/contenttypes/browser/templates/document.pt
 - Location:   (line 6: col 21)
 - Source:     ... tal:use-macro="context/@@main_template/macros/master"
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 - Arguments:  template: <Products.Five.browser.pagetemplatefile.ViewPageTemplateFile object at 0x10e0a4fd0>
               options: {}
               args: ()
               nothing: None
               modules: <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter object at 0x10a559e80>
               request: <WSGIRequest, URL=None>
               view: <Products.Five.viewlet.manager.<ViewletManager providing IToolbar> object at 0x11016a8e0>
               context: <PloneSite at /plone>
               views: <Products.Five.browser.pagetemplatefile.ViewMapper object at 0x110178910>
               here: <PloneSite at /plone>
               container: <PloneSite at /plone>
               root: <Application at >
               traverse_subpath: []
               user: <PloneUser 'test-user'>
               default: <DEFAULT>
               repeat: <Products.PageTemplates.engine.RepeatDictWrapper object at 0x10d7793c0>
               loop: {}
               target_language: None
               translate: <function BaseTemplate.render.<locals>.translate at 0x110168c10>
               attrs: {}
               context_state: <Products.Five.browser.metaconfigure.ContextState object at 0x110178550>
               icons: <Products.Five.browser.metaconfigure.IconsView object at 0x1101871c0>
               personal_bar: <plone.app.layout.viewlets.common.PersonalBarViewlet object at 0x110187280>

I call this branch es6, but it is fine for standard coredev.

mister-roboto commented 2 years ago

@mauritsvanrees thanks for creating this Pull Request and help improve Plone!

To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass.

Whenever you feel that the pull request is ready to be tested, either start all jenkins jobs pull requests by yourself, or simply add a comment in this pull request stating:

@jenkins-plone-org please run jobs

With this simple comment all the jobs will be started automatically.

Happy hacking!

mauritsvanrees commented 2 years ago

@jenkins-plone-org please run jobs

mauritsvanrees commented 2 years ago

I thought I had added a news snippet. But really this is not newsworthy.