Skip to content

KeyError: 'portal' in tests with Python 3.12.1 #1740

@wesleybl

Description

@wesleybl

Tests with Python 3.12.1 are failing:

Traceback (most recent call last):
  File "/home/runner/work/plone.restapi/plone.restapi/bin/test", line 289, in <module>
    sys.exit(zope.testrunner.run((['-s', 'plone.restapi', '--auto-color', '--auto-progress']) + [
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/plone.restapi/plone.restapi/eggs/zope.testrunner-6.1-py3.12.egg/zope/testrunner/__init__.py", line 31, in run
    failed = run_internal(defaults, args, script_parts=script_parts, cwd=cwd,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/plone.restapi/plone.restapi/eggs/zope.testrunner-6.1-py3.12.egg/zope/testrunner/__init__.py", line 55, in run_internal
    runner.run()
  File "/home/runner/work/plone.restapi/plone.restapi/eggs/zope.testrunner-6.1-py3.12.egg/zope/testrunner/runner.py", line 191, in run
    self.run_tests()
  File "/home/runner/work/plone.restapi/plone.restapi/eggs/zope.testrunner-6.1-py3.12.egg/zope/testrunner/runner.py", line 292, in run_tests
    self.ran += run_layer(self.options, layer_name, layer, tests,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/plone.restapi/plone.restapi/eggs/zope.testrunner-6.1-py3.12.egg/zope/testrunner/runner.py", line 473, in run_layer
    return run_tests(options, tests, layer_name, failures, errors, skipped,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/plone.restapi/plone.restapi/eggs/zope.testrunner-6.1-py3.12.egg/zope/testrunner/runner.py", line 399, in run_tests
    test(result)
  File "/opt/hostedtoolcache/Python/3.12.1/x64/lib/python3.12/unittest/case.py", line 692, in __call__
    return self.run(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.1/x64/lib/python3.12/unittest/case.py", line 662, in run
    result.stopTest(self)
  File "/home/runner/work/plone.restapi/plone.restapi/eggs/zope.testrunner-6.1-py3.12.egg/zope/testrunner/runner.py", line 1019, in stopTest
    self.testTearDown()
  File "/home/runner/work/plone.restapi/plone.restapi/eggs/zope.testrunner-6.1-py3.12.egg/zope/testrunner/runner.py", line 891, in testTearDown
    layer.testTearDown()
  File "/home/runner/work/plone.restapi/plone.restapi/eggs/plone.app.testing-7.0.1-py3.12.egg/plone/app/testing/layers.py", line 291, in testTearDown
    self.tearDownEnvironment(self["portal"])
                             ~~~~^^^^^^^^^^
  File "/home/runner/work/plone.restapi/plone.restapi/eggs/plone.testing-8.0.4-py3.12.egg/plone/testing/layer.py", line 30, in __getitem__
    raise KeyError(key)
KeyError: 'portal'

See: https://github.com/plone/plone.restapi/actions/runs/7232945652/job/19707677378

When the tests were run with Python 3.12.0 they worked:

https://github.com/plone/plone.restapi/actions/runs/6999363538/job/19038558131#step:3:13

This appears to be related to: zopefoundation/Zope#1188

I suggest forcing the tests to run with Python 3.12.0, as long as the problem is not fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions