#486 Use unittest.mock
Merged 4 years ago by gnaponie. Opened 4 years ago by cqi.
cqi/freshmaker remove-mock-dep  into  master

@@ -3,7 +3,7 @@ 

  import os

  import sys

  from pprint import pprint

- from mock import patch

+ from unittest.mock import patch

  from logging.config import dictConfig

  import fedmsg.config

  

file modified
-1
@@ -1,7 +1,6 @@ 

  -r requirements.txt

  

  copr

- mock

  pytest

  pytest-cov

  vcrpy

@@ -20,7 +20,7 @@ 

  #

  # Written by Jan Kaluza <jkaluza@redhat.com>

  

- from mock import patch, MagicMock

+ from unittest.mock import patch, MagicMock

  

  import freshmaker

  from freshmaker.errata import ErrataAdvisory

@@ -22,7 +22,7 @@ 

  

  import unittest

  

- from mock import patch

+ from unittest.mock import patch

  

  from freshmaker import events, models, db

  from freshmaker.handlers.internal import CancelEventOnFreshmakerManageRequest

@@ -21,7 +21,7 @@ 

  #

  # Written by Chenxiong Qi <cqi@redhat.com>

  

- from mock import patch, MagicMock, PropertyMock

+ from unittest.mock import patch, MagicMock, PropertyMock

  

  from freshmaker.handlers.internal import GenerateAdvisorySignedEventOnRPMSign

  from freshmaker.errata import ErrataAdvisory

@@ -21,7 +21,7 @@ 

  #

  # Written by Chenxiong Qi <cqi@redhat.com>

  

- from mock import patch, Mock

+ from unittest.mock import patch, Mock

  

  from freshmaker import conf, db

  from freshmaker.errata import ErrataAdvisory

@@ -21,7 +21,7 @@ 

  #

  # Written by Chenxiong Qi <cqi@redhat.com>

  

- from mock import patch, PropertyMock

+ from unittest.mock import patch, PropertyMock

  

  from freshmaker import db

  from freshmaker.models import (

@@ -20,11 +20,12 @@ 

  # SOFTWARE.

  

  import json

- import mock

  import os

  import sys

  import unittest

  

+ from unittest import mock

+ 

  sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))  # noqa

  from tests import get_fedmsg, helpers

  

@@ -20,7 +20,7 @@ 

  # SOFTWARE.

  

  import json

- from mock import patch, PropertyMock, Mock, call

+ from unittest.mock import patch, PropertyMock, Mock, call

  

  import freshmaker

  

file modified
+1 -1
@@ -26,7 +26,7 @@ 

  import unittest

  import koji

  

- from mock import patch, MagicMock, PropertyMock

+ from unittest.mock import patch, MagicMock, PropertyMock

  from functools import wraps

  

  import freshmaker.consumer

file modified
+1 -1
@@ -24,7 +24,7 @@ 

  

  import flask

  

- from mock import patch, Mock

+ from unittest.mock import patch, Mock

  from werkzeug.exceptions import Unauthorized

  

  import freshmaker.auth

file modified
+1 -1
@@ -18,8 +18,8 @@ 

  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

  # SOFTWARE.

  

- import mock

  import unittest

+ from unittest import mock

  

  import freshmaker

  

file modified
+1 -1
@@ -20,7 +20,7 @@ 

  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

  # SOFTWARE.

  

- from mock import patch, MagicMock

+ from unittest.mock import patch, MagicMock

  from requests_kerberos.exceptions import MutualAuthenticationError

  from requests.exceptions import HTTPError

  

file modified
+1 -1
@@ -22,7 +22,7 @@ 

  #

  # Written by Chenxiong Qi <cqi@redhat.com>

  

- from mock import patch

+ from unittest.mock import patch

  import json

  

  import freshmaker

file modified
+1 -1
@@ -21,7 +21,7 @@ 

  #

  # Written by Jan Kaluza <jkaluza@redhat.com>

  

- from mock import MagicMock

+ from unittest.mock import MagicMock

  

  from freshmaker.image_verifier import ImageVerifier

  from tests import helpers

file modified
+1 -1
@@ -25,7 +25,7 @@ 

  import io

  import http.client

  

- from mock import call, patch, Mock

+ from unittest.mock import call, patch, Mock

  

  import freshmaker

  

file modified
+1 -1
@@ -23,7 +23,7 @@ 

  

  import unittest

  

- from mock import patch

+ from unittest.mock import patch

  

  from freshmaker import conf

  from freshmaker import messaging

file modified
+1 -1
@@ -21,7 +21,7 @@ 

  # Written by Jan Kaluza <jkaluza@redhat.com>

  

  import datetime

- from mock import patch

+ from unittest.mock import patch

  

  from freshmaker import db, events

  from freshmaker.models import ArtifactBuild, ArtifactType

file modified
+2 -1
@@ -20,12 +20,13 @@ 

  # SOFTWARE.

  

  import os

- import mock

  import pytest

  import freshmaker

  import requests

  import importlib

  

+ from unittest import mock

+ 

  from freshmaker import app, db, events, models, login_manager

  from tests import helpers

  

file modified
+1 -1
@@ -22,7 +22,7 @@ 

  # Written by Chenxiong Qi <cqi@redhat.com>

  #            Jan kaluza <jkaluza@redhat.com>

  

- from mock import patch, Mock

+ from unittest.mock import patch, Mock

  from odcs.client.odcs import AuthMech

  

  from freshmaker import conf, db

file modified
+1 -1
@@ -24,7 +24,7 @@ 

  

  import koji

  

- from mock import patch, MagicMock

+ from unittest.mock import patch, MagicMock

  import queue

  

  from freshmaker import db

file modified
+1 -1
@@ -23,7 +23,7 @@ 

  

  import json

  

- from mock import patch

+ from unittest.mock import patch

  

  from freshmaker.pulp import Pulp

  from tests import helpers

file modified
+1 -1
@@ -20,7 +20,7 @@ 

  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

  # SOFTWARE.

  

- from mock import patch, MagicMock

+ from unittest.mock import patch, MagicMock

  

  from freshmaker.sfm2 import SFM2API

  from tests import helpers

file modified
+1 -1
@@ -26,7 +26,7 @@ 

  import contextlib

  import flask

  

- from mock import patch

+ from unittest.mock import patch

  

  from freshmaker import app, db, events, models, login_manager

  from freshmaker.types import ArtifactType, ArtifactBuildState, EventState

unittest.mock is included in Python 3, no need to install mock
separately.

Signed-off-by: Chenxiong Qi cqi@redhat.com

Commit 63f9e62 fixes this pull-request

Pull-Request has been merged by gnaponie

4 years ago

Pull-Request has been merged by gnaponie

4 years ago