Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace mock with unittest.mock #1207

Open
kdmccormick opened this issue May 22, 2024 · 0 comments
Open

Replace mock with unittest.mock #1207

kdmccormick opened this issue May 22, 2024 · 0 comments
Labels
good first issue A good task for a newcomer to start with help wanted Ready to be picked up by anyone in the community

Comments

@kdmccormick
Copy link
Member

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 ...

@kdmccormick kdmccormick added help wanted Ready to be picked up by anyone in the community good first issue A good task for a newcomer to start with labels Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue A good task for a newcomer to start with help wanted Ready to be picked up by anyone in the community
Projects
None yet
Development

No branches or pull requests

1 participant