refactor: switch from mock to unittest.mock (#34844)
As of Python 3.3, the 3rd-party `mock` package has been subsumed into the standard `unittest.mock` package. Refactoring tests to use the latter will allow us to drop `mock` as a dependency, which is currently coming in transitively through requirements/edx/paver.in. We don't actually drop the `mock` dependency in this PR. That will happen naturally in: * https://github.com/openedx/edx-platform/pull/34830
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
Tests for the Catalog apps `api.py` functions.
|
||||
"""
|
||||
from mock import patch
|
||||
from unittest.mock import patch
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
course_overview api tests
|
||||
"""
|
||||
from mock import patch
|
||||
from unittest.mock import patch
|
||||
|
||||
from django.http.response import Http404
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
"""
|
||||
Tests for discussions tasks.
|
||||
"""
|
||||
from unittest import mock
|
||||
|
||||
import ddt
|
||||
import mock
|
||||
from edx_toggles.toggles.testutils import override_waffle_flag
|
||||
from openedx_events.learning.data import DiscussionTopicContext
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
"""
|
||||
Tests for Management commands of comprehensive theming.
|
||||
"""
|
||||
|
||||
from django.core.management import call_command
|
||||
from django.test import TestCase, override_settings
|
||||
from unittest.mock import patch
|
||||
|
||||
import pavelib.assets
|
||||
|
||||
|
||||
class TestUpdateAssets(TestCase):
|
||||
"""
|
||||
Test comprehensive theming helper functions.
|
||||
"""
|
||||
|
||||
@patch.object(pavelib.assets, 'sh')
|
||||
@override_settings(COMPREHENSIVE_THEME_DIRS='common/test')
|
||||
def test_deprecated_wrapper(self, mock_sh):
|
||||
call_command('compile_sass', '--themes', 'fake-theme1', 'fake-theme2')
|
||||
assert mock_sh.called_once_with(
|
||||
"npm run compile-sass -- " +
|
||||
"--theme-dir common/test --theme fake-theme-1 --theme fake-theme-2"
|
||||
)
|
||||
Reference in New Issue
Block a user