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:
@@ -6,10 +6,10 @@ import io
|
||||
import os
|
||||
import os.path
|
||||
import xml.sax.saxutils as saxutils
|
||||
from unittest.mock import MagicMock, Mock
|
||||
|
||||
import fs.osfs
|
||||
from mako.lookup import TemplateLookup
|
||||
from mock import MagicMock, Mock
|
||||
from path import Path
|
||||
|
||||
from xmodule.capa.capa_problem import LoncapaProblem, LoncapaSystem
|
||||
|
||||
@@ -3,6 +3,7 @@ Test capa problem.
|
||||
"""
|
||||
import textwrap
|
||||
import unittest
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
from django.conf import settings
|
||||
from django.test import override_settings
|
||||
@@ -10,7 +11,6 @@ import pytest
|
||||
import ddt
|
||||
from lxml import etree
|
||||
from markupsafe import Markup
|
||||
from mock import patch, MagicMock
|
||||
|
||||
from xmodule.capa.correctmap import CorrectMap
|
||||
from xmodule.capa.responsetypes import LoncapaProblemError
|
||||
|
||||
@@ -6,9 +6,9 @@ CAPA HTML rendering tests.
|
||||
import os
|
||||
import textwrap
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import ddt
|
||||
import mock
|
||||
from lxml import etree
|
||||
from xmodule.capa.tests.helpers import new_loncapa_problem, test_capa_system
|
||||
from openedx.core.djangolib.markup import HTML
|
||||
|
||||
@@ -23,12 +23,12 @@ import textwrap
|
||||
import unittest
|
||||
import xml.sax.saxutils as saxutils
|
||||
from collections import OrderedDict
|
||||
from unittest.mock import ANY, patch
|
||||
|
||||
import pytest
|
||||
import six
|
||||
from lxml import etree
|
||||
from lxml.html import fromstring
|
||||
from mock import ANY, patch
|
||||
from pyparsing import ParseException
|
||||
from six.moves import zip
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ import textwrap
|
||||
import unittest
|
||||
import zipfile
|
||||
from datetime import datetime
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
import calc
|
||||
import mock
|
||||
import pyparsing
|
||||
import random2 as random
|
||||
import requests
|
||||
|
||||
Reference in New Issue
Block a user