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:
Kyle McCormick
2024-05-22 13:52:24 -04:00
committed by GitHub
parent 749e18bcee
commit 11626148d9
30 changed files with 49 additions and 73 deletions

View File

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

View File

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

View File

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

View File

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

View File

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