Roundup Tracker - Issues


Author rouilj
Recipients rouilj, schlatterbeck
Date 2022-11-23.15:25:04
Message-id <>

  import mock
except ImportError:
  import unittest.mock as mock

I have no error of that type in CI (ubuntu 3.11 and lower). What is your

On my dev system (ubuntu 20.04):

>>> import sys
>>> import mock
>>> sys.modules['mock']
<module 'mock' from '/usr/lib/python3/dist-packages/mock/'>
>>> sys.version
'3.6.9 (default, Jun 29 2022, 11:45:57) \n[GCC 8.4.0]'

but on my rasp pi:

>>> import sys
>>> import mock
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mock'
>>> sys.version
'3.9.2 (default, Mar 12 2021, 04:06:34) \n[GCC 10.2.1 20210110]'

searching for python mock I get:

>>> import unittest.mock
>>> sys.modules['unittest.mock']
<module 'unittest.mock' from '/usr/lib/python3.9/unittest/'>

and the code reads:

    def test_native_autoselect(self):
        import mock, sys
        with mock.patch.dict('sys.modules',
and the unitest.mock.patch() is a context manager. So I am going with that.

but google isn't showing any indication that it moved.

pip3 shows mock 2.0.0 and references unittest.mock as of python 3.3.

My guess is mock/ was installed as a (default) package in some python

  % dpkg -S /usr/lib/python3/dist-packages/mock/
  python3-mock: /usr/lib/python3/dist-packages/mock/
Date User Action Args
2022-11-23 15:25:05rouiljsetmessageid: <>
2022-11-23 15:25:05rouiljsetrecipients: + rouilj, schlatterbeck
2022-11-23 15:25:05rouiljlinkissue2551242 messages
2022-11-23 15:25:04rouiljcreate