Python 3.10 abstract base class collections error

Bug #1954327 reported by Corey Bryant
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
testresources
Fix Released
Undecided
Unassigned

Bug Description

When running 'tox -e py310' unit tests for the heat project, it errored as follows:

py310 create: /home/corey/pkg/yoga/upstream/heat/.tox/py310
py310 installdeps: -chttps://releases.openstack.org/constraints/upper/master, -r/home/corey/pkg/yoga/upstream/heat/requirements.txt, -r/home/corey/pkg/yoga/upstream/heat/test-requirements.txt
py310 develop-inst: /home/corey/pkg/yoga/upstream/heat
py310 installed: /home/corey/pkg/yoga/upstream/heat/.tox/py310/lib/python3.10/site-packages/pip/_internal/cli/cmdoptions.py:18: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives, from distutils.util import strtobool,/home/corey/pkg/yoga/upstream/heat/.tox/py310/lib/python3.10/site-packages/pip/_internal/locations.py:14: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead, from distutils import sysconfig as distutils_sysconfig,alembic==1.7.5,amqp==5.0.6,aodhclient==2.3.0,appdirs==1.4.4,attrs==21.2.0,autopage==0.4.0,Babel==2.9.1,bandit==1.7.1,bcrypt==3.2.0,beautifulsoup4==4.10.0,cachetools==4.2.4,certifi==2021.10.8,cffi==1.15.0,charset-normalizer==2.0.9,cliff==3.10.0,cmd2==2.3.3,coverage==6.2,croniter==1.1.0,cryptography==36.0.0,ddt==1.4.4,debtcollector==2.3.0,decorator==5.1.0,dnspython==2.1.0,doc8==0.10.1,docker==5.0.3,docutils==0.17.1,dogpile.cache==1.1.4,entrypoints==0.3,eventlet==0.33.0,extras==1.0.0,fasteners==0.14.1,fixtures==3.0.0,flake8==3.7.9,future==0.18.2,futurist==2.4.0,gitdb==4.0.9,GitPython==3.1.24,greenlet==1.1.2,hacking==3.0.1,idna==3.3,iso8601==1.0.2,Jinja2==3.0.3,jmespath==0.10.0,jsonpatch==1.32,jsonpointer==2.2,jsonschema==3.2.0,keystoneauth1==4.4.0,keystonemiddleware==9.3.0,kombu==5.2.2,linecache2==1.0.0,logutils==0.3.5,lxml==4.6.4,Mako==1.1.6,MarkupSafe==2.0.1,mccabe==0.6.1,monotonic==1.6,msgpack==1.0.3,munch==2.5.0,netaddr==0.8.0,netifaces==0.11.0,networkx==2.6.3,neutron-lib==2.17.0,-e git+https://opendev.org/openstack/heat@fe8fba8c9823fd001524fe8a2a59b6be201faec4#egg=openstack_heat,openstacksdk==0.61.0,os-client-config==2.1.0,os-ken==2.3.0,os-service-types==1.7.0,os-traits==2.6.0,osc-lib==2.4.2,oslo.cache==2.8.1,oslo.concurrency==4.5.0,oslo.config==8.7.1,oslo.context==3.4.0,oslo.db==11.1.0,oslo.i18n==5.1.0,oslo.log==4.6.1,oslo.messaging==12.11.0,oslo.metrics==0.4.0,oslo.middleware==4.5.0,oslo.policy==3.10.0,oslo.reports==2.3.0,oslo.serialization==4.2.0,oslo.service==2.7.0,oslo.upgradecheck==1.4.0,oslo.utils==4.12.0,oslo.versionedobjects==2.5.0,oslotest==4.5.0,osprofiler==3.4.2,ovs==2.16.0,packaging==21.3,paramiko==2.8.1,Paste==3.5.0,PasteDeploy==2.1.1,pbr==5.8.0,pecan==1.3.3,ply==3.11,prettytable==2.4.0,prometheus-client==0.12.0,psutil==5.8.0,pycadf==3.1.1,pycodestyle==2.5.0,pycparser==2.21,pydot==1.4.2,pyflakes==2.1.1,Pygments==2.10.0,pyinotify==0.9.6,PyMySQL==1.0.2,PyNaCl==1.4.0,pyOpenSSL==21.0.0,pyparsing==3.0.6,pyperclip==1.8.2,pyrsistent==0.18.0,python-barbicanclient==5.2.0,python-blazarclient==3.3.1,python-cinderclient==8.2.0,python-dateutil==2.8.2,python-designateclient==4.4.0,python-glanceclient==3.5.0,python-heatclient==2.4.0,python-ironicclient==4.9.0,python-keystoneclient==4.3.0,python-magnumclient==3.5.0,python-manilaclient==3.1.0,python-mistralclient==4.3.0,python-monascaclient==2.4.0,python-neutronclient==7.7.0,python-novaclient==17.6.0,python-octaviaclient==2.4.0,python-openstackclient==5.7.0,python-saharaclient==3.4.0,python-subunit==1.4.0,python-swiftclient==3.13.0,python-troveclient==7.1.1,python-vitrageclient==4.4.0,python-zaqarclient==2.2.0,python-zunclient==4.3.0,pytz==2021.3,PyYAML==6.0,repoze.lru==0.7,requests==2.26.0,requestsexceptions==1.4.0,restructuredtext-lint==1.3.2,rfc3986==1.5.0,Routes==2.5.1,setproctitle==1.2.2,simplejson==3.17.6,six==1.16.0,smmap==5.0.0,sortedcontainers==2.4.0,soupsieve==2.3.1,SQLAlchemy==1.4.27,sqlalchemy-migrate==0.13.0,sqlparse==0.4.2,statsd==3.3.0,stestr==3.2.1,stevedore==3.5.0,tempest==29.2.0,Tempita==0.5.2,tenacity==6.3.1,testresources==2.0.1,testscenarios==0.5.0,testtools==2.5.0,traceback2==1.4.0,unittest2==1.1.0,urllib3==1.26.7,vine==5.0.0,voluptuous==0.12.2,waitress==2.0.0,warlock==1.3.3,wcwidth==0.2.5,WebOb==1.8.7,websocket-client==1.2.3,WebTest==3.0.0,wrapt==1.13.3,yappi==1.3.3,yaql==2.0.0
py310 run-test-pre: PYTHONHASHSEED='1057012293'
py310 run-test: commands[0] | stestr run
Readline features including tab completion have been disabled because
no supported version of readline was found. To resolve this, install
pyreadline on Windows or gnureadline on Mac.

/home/corey/pkg/yoga/upstream/heat/.tox/py310/lib/python3.10/site-packages/testtools/distutilscmd.py:7: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  from distutils.core import Command
/home/corey/pkg/yoga/upstream/heat/.tox/py310/lib/python3.10/site-packages/future/standard_library/__init__.py:65: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
  import imp
/home/corey/pkg/yoga/upstream/heat/.tox/py310/lib/python3.10/site-packages/testtools/distutilscmd.py:7: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  from distutils.core import Command

=========================
Failures during discovery
=========================
--- import errors ---
Failed to import test module: heat.tests.db.test_migrations
Traceback (most recent call last):
  File "/usr/lib/python3.10/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.10/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/home/corey/pkg/yoga/upstream/heat/heat/tests/db/test_migrations.py", line 28, in <module>
    from oslo_db.sqlalchemy import test_fixtures
  File "/home/corey/pkg/yoga/upstream/heat/.tox/py310/lib/python3.10/site-packages/oslo_db/sqlalchemy/test_fixtures.py", line 18, in <module>
    import testresources
  File "/home/corey/pkg/yoga/upstream/heat/.tox/py310/lib/python3.10/site-packages/testresources/__init__.py", line 24, in <module>
    import unittest2
  File "/home/corey/pkg/yoga/upstream/heat/.tox/py310/lib/python3.10/site-packages/unittest2/__init__.py", line 40, in <module>
    from unittest2.collector import collector
  File "/home/corey/pkg/yoga/upstream/heat/.tox/py310/lib/python3.10/site-packages/unittest2/collector.py", line 3, in <module>
    from unittest2.loader import defaultTestLoader
  File "/home/corey/pkg/yoga/upstream/heat/.tox/py310/lib/python3.10/site-packages/unittest2/loader.py", line 13, in <module>
    from unittest2 import case, suite, util
  File "/home/corey/pkg/yoga/upstream/heat/.tox/py310/lib/python3.10/site-packages/unittest2/case.py", line 18, in <module>
    from unittest2 import result
  File "/home/corey/pkg/yoga/upstream/heat/.tox/py310/lib/python3.10/site-packages/unittest2/result.py", line 10, in <module>
    from unittest2.compatibility import wraps
  File "/home/corey/pkg/yoga/upstream/heat/.tox/py310/lib/python3.10/site-packages/unittest2/compatibility.py", line 143, in <module>
    class ChainMap(collections.MutableMapping):
AttributeError: module 'collections' has no attribute 'MutableMapping'

================================================================================
The above traceback was encountered during test discovery which imports all the found test modules in the specified test_path.
ERROR: InvocationError for command /home/corey/pkg/yoga/upstream/heat/.tox/py310/bin/stestr run (exited with code 100)
___________________________________ summary ____________________________________
ERROR: py310: commands failed

The fix is simple, in py310, we just need to use collections.abc.MutableMapping. However, should testresources still be using unittest2 in the first place?

[1] https://docs.python.org/3.10/library/collections.abc.html#collections-abstract-base-classes

Revision history for this message
Corey Bryant (corey.bryant) wrote :

This has been patched in unittest2. For pip, unittest2 just needs a release to pypi.

Jelmer Vernooij (jelmer)
Changed in testresources:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.