openedx / edx-proctoring

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Replace `mock` with `unittest.mock`

kdmccormick opened this issue · comments

As of Python 3.3, unittest.mock is a drop-in replacement for mock. For example: openedx/edx-platform#34844

This package uses mock, but is not declaring it as a base dependency, which is causing an error when we remove mock from edx-platform:

2024-05-22T16:22:27.2828453Z _____ ERROR collecting lms/djangoapps/instructor/tests/test_proctoring.py ______
2024-05-22T16:22:27.2829424Z ImportError while importing test module '/runner/_work/edx-platform/edx-platform/lms/djangoapps/instructor/tests/test_proctoring.py'.
2024-05-22T16:22:27.2830399Z Hint: make sure your test modules/packages have valid Python names.
2024-05-22T16:22:27.2830803Z Traceback:
2024-05-22T16:22:27.2831294Z /opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/importlib/__init__.py:126: in import_module
2024-05-22T16:22:27.2831964Z     return _bootstrap._gcd_import(name[level:], package, level)
2024-05-22T16:22:27.2832495Z lms/djangoapps/instructor/tests/test_proctoring.py:12: in <module>
2024-05-22T16:22:27.2833096Z     from edx_proctoring.backends.tests.test_backend import TestBackendProvider
2024-05-22T16:22:27.2834054Z /opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/edx_proctoring/backends/tests/test_backend.py:7: in <module>
2024-05-22T16:22:27.2834749Z     from mock import patch
2024-05-22T16:22:27.2835112Z E   ModuleNotFoundError: No module named 'mock'

The fix is to simply replace occurances of from mock import ... with from unittest.mock import ...