Use unittest.mock instead of mock
The mock third party library was needed for mock support in py2 runtimes. Since we now only support py36 and later, we can use the standard lib unittest.mock module instead. Change-Id: Id4029239c345655ea7ffc90b5969b29b47a84955
This commit is contained in:
@@ -9,7 +9,6 @@
|
|||||||
#
|
#
|
||||||
charm-tools>=2.4.4
|
charm-tools>=2.4.4
|
||||||
requests>=2.18.4
|
requests>=2.18.4
|
||||||
mock>=1.2
|
|
||||||
flake8>=2.2.4,<=2.4.1
|
flake8>=2.2.4,<=2.4.1
|
||||||
stestr>=2.2.0
|
stestr>=2.2.0
|
||||||
coverage>=4.5.2
|
coverage>=4.5.2
|
||||||
|
@@ -18,12 +18,12 @@ import sys
|
|||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import mock
|
from unittest import mock
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from unit_tests.test_utils import CharmTestCase
|
from unit_tests.test_utils import CharmTestCase
|
||||||
|
|
||||||
from mock import patch, MagicMock
|
from unittest.mock import patch, MagicMock
|
||||||
|
|
||||||
# python-apt is not installed as part of test-requirements but is imported by
|
# python-apt is not installed as part of test-requirements but is imported by
|
||||||
# some charmhelpers modules so create a fake import.
|
# some charmhelpers modules so create a fake import.
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from mock import patch, MagicMock
|
from unittest.mock import patch, MagicMock
|
||||||
|
|
||||||
os.environ['JUJU_UNIT_NAME'] = 'swift-storage'
|
os.environ['JUJU_UNIT_NAME'] = 'swift-storage'
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@ import sys
|
|||||||
import unittest
|
import unittest
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
from mock import (
|
from unittest.mock import (
|
||||||
patch,
|
patch,
|
||||||
mock_open,
|
mock_open,
|
||||||
MagicMock,
|
MagicMock,
|
||||||
|
@@ -17,7 +17,7 @@ import tempfile
|
|||||||
import unittest
|
import unittest
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from lib.misc_utils import ensure_block_device
|
from lib.misc_utils import ensure_block_device
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
from unit_tests.test_utils import CharmTestCase, patch_open
|
from unit_tests.test_utils import CharmTestCase, patch_open
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from mock import patch
|
from unittest.mock import patch
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from mock import call, patch, MagicMock
|
from unittest.mock import call, patch, MagicMock
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import mock
|
from unittest import mock
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from jinja2 import Environment
|
from jinja2 import Environment
|
||||||
|
@@ -19,7 +19,7 @@ import unittest
|
|||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
|
||||||
def load_config():
|
def load_config():
|
||||||
|
Reference in New Issue
Block a user