#336 Getting rid of python3-mock
Merged 3 years ago by clime. Opened 3 years ago by clime.

<a class="font-weight-bold ml-2" href="/copr/copr/blob/ce9ea1ae69c186ff588c6f2c0f4c7702f5984e2e/f/backend/copr-backend.spec" title="View file as of ce9ea1a">backend/copr-backend.spec</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-1</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/ce9ea1ae69c186ff588c6f2c0f4c7702f5984e2e/f/backend/copr-backend.spec" title="View file as of ce9ea1a"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_1"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -30,7 +30,6 @@ 

  

  BuildRequires: python3-pytest

  BuildRequires: python3-pytest-cov

- BuildRequires: python3-mock

  BuildRequires: python3-munch

  BuildRequires: python3-lockfile

  BuildRequires: python3-daemon

<a class="font-weight-bold ml-2" href="/copr/copr/blob/b9358961ce58b9b7ea8d21b4f0203b5d6f66e257/f/backend/tests/daemons/test_backend.py" title="View file as of b935896">backend/tests/daemons/test_backend.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+2</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-2</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/b9358961ce58b9b7ea8d21b4f0203b5d6f66e257/f/backend/tests/daemons/test_backend.py" title="View file as of b935896"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_2"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -13,8 +13,8 @@ 

  from backend.daemons.backend import CoprBackend, run_backend

  from backend.exceptions import CoprBackendError

  

- import mock

- from mock import MagicMock

+ from unittest import mock

+ from unittest.mock import MagicMock

  

  STDOUT = "stdout"

  STDERR = "stderr"

<a class="font-weight-bold ml-2" href="/copr/copr/blob/49b1464cc8c1e8f437c1bdab61eb3d5e10425b3a/f/backend/tests/daemons/test_dispatcher.py" title="View file as of 49b1464">backend/tests/daemons/test_dispatcher.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+2</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-2</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/49b1464cc8c1e8f437c1bdab61eb3d5e10425b3a/f/backend/tests/daemons/test_dispatcher.py" title="View file as of 49b1464"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_3"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -16,8 +16,8 @@ 

  from backend.job import BuildJob

  from backend.vm_manage.models import VmDescriptor

  

- import mock

- from mock import MagicMock

+ from unittest import mock

+ from unittest.mock import MagicMock

  

  from backend.daemons.dispatcher import Worker

  

<a class="font-weight-bold ml-2" href="/copr/copr/blob/cd01b642ab5eeb1607cd3df49e1d1926c73e8e1c/f/backend/tests/daemons/test_job_grab.py" title="View file as of cd01b64">backend/tests/daemons/test_job_grab.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+2</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-2</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/cd01b642ab5eeb1607cd3df49e1d1926c73e8e1c/f/backend/tests/daemons/test_job_grab.py" title="View file as of cd01b64"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_4"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -16,8 +16,8 @@ 

  import shutil

  import os

  

- import mock

- from mock import patch, MagicMock, call

+ from unittest import mock

+ from unittest.mock import patch, MagicMock, call

  import pytest

  

  from backend.daemons.job_grab import CoprJobGrab

<a class="font-weight-bold ml-2" href="/copr/copr/blob/28ee9cd37d1967d78c59e5def984c968339cf50a/f/backend/tests/daemons/test_log.py" title="View file as of 28ee9cd">backend/tests/daemons/test_log.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+3</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-3</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/28ee9cd37d1967d78c59e5def984c968339cf50a/f/backend/tests/daemons/test_log.py" title="View file as of 28ee9cd"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_5"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -7,11 +7,11 @@ 

  import tempfile

  import shutil

  import os

- 

- import mock

- from mock import patch, MagicMock

  import pytest

  

+ from unittest import mock

+ from unittest.mock import patch, MagicMock

+ 

  import backend.daemons.log as log_module

  from backend.daemons.log import RedisLogHandler

  

<a class="font-weight-bold ml-2" href="/copr/copr/blob/aad87036af79f4dbe2527478c20d808c4ca59da0/f/backend/tests/daemons/test_vm_master.py" title="View file as of aad8703">backend/tests/daemons/test_vm_master.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+2</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-2</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/aad87036af79f4dbe2527478c20d808c4ca59da0/f/backend/tests/daemons/test_vm_master.py" title="View file as of aad8703"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_6"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -22,8 +22,8 @@ 

  from backend.constants import JOB_GRAB_TASK_END_PUBSUB

  from backend.exceptions import VmError, VmSpawnLimitReached

  

- import mock

- from mock import patch, MagicMock

+ from unittest import mock

+ from unittest.mock import patch, MagicMock

  import pytest

  

  

<a class="font-weight-bold ml-2" href="/copr/copr/blob/96a848734ce7d51d9a3db9cb4cfefb03ad66d294/f/backend/tests/mockremote/test_builder.py" title="View file as of 96a8487">backend/tests/mockremote/test_builder.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+2</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-2</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/96a848734ce7d51d9a3db9cb4cfefb03ad66d294/f/backend/tests/mockremote/test_builder.py" title="View file as of 96a8487"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_7"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -13,8 +13,8 @@ 

  

  from backend.job import BuildJob

  

- import mock

- from mock import patch, MagicMock

+ from unittest import mock

+ from unittest.mock import patch, MagicMock

  import pytest

  from types import MethodType

  

<a class="font-weight-bold ml-2" href="/copr/copr/blob/400ed191464ad0885a03cc7e9f28932f1d1ea155/f/backend/tests/mockremote/test_mockremote.py" title="View file as of 400ed19">backend/tests/mockremote/test_mockremote.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+2</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-2</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/400ed191464ad0885a03cc7e9f28932f1d1ea155/f/backend/tests/mockremote/test_mockremote.py" title="View file as of 400ed19"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_8"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -9,8 +9,8 @@ 

  import shutil

  import os

  

- import mock

- from mock import patch, MagicMock

+ from unittest import mock

+ from unittest.mock import patch, MagicMock

  import pytest

  

  from backend.mockremote import MockRemote

<a class="font-weight-bold ml-2" href="/copr/copr/blob/8bfa423d21a4e58b53688ed7d45750c1026565a4/f/backend/tests/run/test_copr_prune_results.py" title="View file as of 8bfa423">backend/tests/run/test_copr_prune_results.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+2</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-2</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/8bfa423d21a4e58b53688ed7d45750c1026565a4/f/backend/tests/run/test_copr_prune_results.py" title="View file as of 8bfa423"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_9"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -7,8 +7,8 @@ 

  from munch import Munch

  

  import pytest

- import mock

- from mock import MagicMock

+ from unittest import mock

+ from unittest.mock import MagicMock

  

  from copr_prune_results import Pruner

  from copr_prune_results import main as prune_main

<a class="font-weight-bold ml-2" href="/copr/copr/blob/687aae503c1357bbcfd629087413c5f050c53c35/f/backend/tests/test_action.py" title="View file as of 687aae5">backend/tests/test_action.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+2</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-2</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/687aae503c1357bbcfd629087413c5f050c53c35/f/backend/tests/test_action.py" title="View file as of 687aae5"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_10"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -8,8 +8,8 @@ 

  

  import pytest

  

- import mock

- from mock import MagicMock

+ from unittest import mock

+ from unittest.mock import MagicMock

  

  from backend.actions import Action, ActionType, ActionResult

  from backend.exceptions import CreateRepoError, CoprKeygenRequestError

<a class="font-weight-bold ml-2" href="/copr/copr/blob/359e64134305214be54dd5120b392ae066d6dd0b/f/backend/tests/test_createrepo.py" title="View file as of 359e641">backend/tests/test_createrepo.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+2</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-2</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/359e64134305214be54dd5120b392ae066d6dd0b/f/backend/tests/test_createrepo.py" title="View file as of 359e641"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_11"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -6,8 +6,8 @@ 

  import time

  import pytest

  

- import mock

- from mock import MagicMock

+ from unittest import mock

+ from unittest.mock import MagicMock

  

  from backend.createrepo import createrepo, createrepo_unsafe, add_appdata, run_cmd_unsafe

  from backend.exceptions import CreateRepoError

<a class="font-weight-bold ml-2" href="/copr/copr/blob/37885de911e33e0b41df274ab1b451b9afd390df/f/backend/tests/test_frontend.py" title="View file as of 37885de">backend/tests/test_frontend.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+2</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-2</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/37885de911e33e0b41df274ab1b451b9afd390df/f/backend/tests/test_frontend.py" title="View file as of 37885de"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_12"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -7,8 +7,8 @@ 

  

  from backend.frontend import FrontendClient

  

- import mock

- from mock import MagicMock

+ from unittest import mock

+ from unittest.mock import MagicMock

  import pytest

  

  @pytest.yield_fixture

<a class="font-weight-bold ml-2" href="/copr/copr/blob/985aef5140da6bd104baa26dd960f0ad62c1fea8/f/backend/tests/test_sign.py" title="View file as of 985aef5">backend/tests/test_sign.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+2</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-2</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/985aef5140da6bd104baa26dd960f0ad62c1fea8/f/backend/tests/test_sign.py" title="View file as of 985aef5"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_13"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -8,8 +8,8 @@ 

  

  from backend.exceptions import CoprSignError, CoprSignNoKeyError, CoprKeygenRequestError

  

- import mock

- from mock import MagicMock

+ from unittest import mock

+ from unittest.mock import MagicMock

  

  from backend.sign import get_pubkey, _sign_one, sign_rpms_in_dir, create_user_keys

  

<a class="font-weight-bold ml-2" href="/copr/copr/blob/8039bb2fece11a9e5f53892200e824ec7c01899d/f/backend/tests/vm_manager/test_check.py" title="View file as of 8039bb2">backend/tests/vm_manager/test_check.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+2</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-2</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/8039bb2fece11a9e5f53892200e824ec7c01899d/f/backend/tests/vm_manager/test_check.py" title="View file as of 8039bb2"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_14"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -15,8 +15,8 @@ 

  from backend.vm_manage import EventTopics, PUBSUB_MB

  from backend.vm_manage.check import HealthChecker, check_health

  

- import mock

- from mock import MagicMock

+ from unittest import mock

+ from unittest.mock import MagicMock

  import pytest

  

  

<a class="font-weight-bold ml-2" href="/copr/copr/blob/41344cc0615ac855fec637d4e2195c45e699b90d/f/backend/tests/vm_manager/test_event_handle.py" title="View file as of 41344cc">backend/tests/vm_manager/test_event_handle.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+2</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-2</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/41344cc0615ac855fec637d4e2195c45e699b90d/f/backend/tests/vm_manager/test_event_handle.py" title="View file as of 41344cc"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_15"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -15,8 +15,8 @@ 

  from backend.vm_manage.event_handle import EventHandler, Recycle

  from backend.vm_manage.models import VmDescriptor

  

- import mock

- from mock import MagicMock

+ from unittest import mock

+ from unittest.mock import MagicMock

  import pytest

  

  

<a class="font-weight-bold ml-2" href="/copr/copr/blob/ede58ca4515d6060211e1166366caf5a4b7e17a7/f/backend/tests/vm_manager/test_executor.py" title="View file as of ede58ca">backend/tests/vm_manager/test_executor.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+1</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-1</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/ede58ca4515d6060211e1166366caf5a4b7e17a7/f/backend/tests/vm_manager/test_executor.py" title="View file as of ede58ca"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_16"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -9,7 +9,7 @@ 

  from backend.helpers import get_redis_connection

  from backend.vm_manage.executor import Executor

  

- import mock

+ from unittest import mock

  import pytest

  

  

<a class="font-weight-bold ml-2" href="/copr/copr/blob/a5213a5d5d745ea2eb7e2d467d52cd808a26a897/f/backend/tests/vm_manager/test_manager.py" title="View file as of a5213a5">backend/tests/vm_manager/test_manager.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+2</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-2</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/a5213a5d5d745ea2eb7e2d467d52cd808a26a897/f/backend/tests/vm_manager/test_manager.py" title="View file as of a5213a5"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_17"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -15,8 +15,8 @@ 

  from backend.daemons.vm_master import VmMaster

  from backend.helpers import get_redis_connection

  

- import mock

- from mock import MagicMock

+ from  unittest import mock

+ from unittest.mock import MagicMock

  import pytest

  

  

<a class="font-weight-bold ml-2" href="/copr/copr/blob/36b9baeb3d76cfb8cdd7dbf75fd2e44d02ef5193/f/backend/tests/vm_manager/test_spawn.py" title="View file as of 36b9bae">backend/tests/vm_manager/test_spawn.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+2</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-2</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/36b9baeb3d76cfb8cdd7dbf75fd2e44d02ef5193/f/backend/tests/vm_manager/test_spawn.py" title="View file as of 36b9bae"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_18"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -12,8 +12,8 @@ 

  from backend.helpers import get_redis_connection

  from backend.vm_manage.spawn import Spawner, spawn_instance, do_spawn_and_publish

  

- import mock

- from mock import MagicMock

+ from unittest import mock

+ from unittest.mock import MagicMock

  import pytest

  

  

<a class="font-weight-bold ml-2" href="/copr/copr/blob/6807007058057203461fa7a39b625112177f97b8/f/backend/tests/vm_manager/test_terminate.py" title="View file as of 6807007">backend/tests/vm_manager/test_terminate.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+2</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-2</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/6807007058057203461fa7a39b625112177f97b8/f/backend/tests/vm_manager/test_terminate.py" title="View file as of 6807007"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_19"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -14,8 +14,8 @@ 

  from backend.vm_manage import EventTopics

  from backend.vm_manage.terminate import Terminator, terminate_vm

  

- import mock

- from mock import MagicMock

+ from unittest import mock

+ from unittest.mock import MagicMock

  import pytest

  

  

<a class="font-weight-bold ml-2" href="/copr/copr/blob/2f42f03adaf2ff4e327516287971588035a36256/f/dist-git/copr-dist-git.spec" title="View file as of 2f42f03">dist-git/copr-dist-git.spec</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-1</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/2f42f03adaf2ff4e327516287971588035a36256/f/dist-git/copr-dist-git.spec" title="View file as of 2f42f03"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_20"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -18,7 +18,6 @@ 

  BuildRequires: python3-munch

  BuildRequires: python3-requests

  BuildRequires: python3-rpkg

- BuildRequires: python3-mock

  BuildRequires: python3-pytest

  BuildRequires: python3-pytest-cov

  

<a class="font-weight-bold ml-2" href="/copr/copr/blob/d961140bfc91878136ba4d28520df28da8584be8/f/dist-git/tests/test_crazy_merging.py" title="View file as of d961140">dist-git/tests/test_crazy_merging.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+2</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-1</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/d961140bfc91878136ba4d28520df28da8584be8/f/dist-git/tests/test_crazy_merging.py" title="View file as of d961140"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_21"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -5,9 +5,10 @@ 

  import shutil

  import time

  import os

- import mock

  import logging

  

+ from unittest import mock

+ 

  from munch import Munch

  from subprocess import check_output

  

<a class="font-weight-bold ml-2" href="/copr/copr/blob/5c2526d2b0403a0cac2fb29ed691d4a15975a9ec/f/dist-git/tests/test_importer.py" title="View file as of 5c2526d">dist-git/tests/test_importer.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+4</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-6</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/5c2526d2b0403a0cac2fb29ed691d4a15975a9ec/f/dist-git/tests/test_importer.py" title="View file as of 5c2526d"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_22"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -6,9 +6,7 @@ 

  import copy

  import pytest

  

- from mock import call

  from munch import Munch

- 

  from base import Base

  

  from unittest import mock
@@ -120,10 +118,10 @@ 

          assert mc_import_package.call_args[0][3] == 'somepath.src.rpm'

  

          print(self.importer.post_back_safe.has_calls([

-             call({'build_id': 125, 'pkg_name': 'foo', 'branch': self.BRANCH,

-                   'pkg_version': '1.2', 'git_hash': '123', 'repo_name': 'foo'}),

-             call({'build_id': 125, 'pkg_name': 'foo', 'branch': self.BRANCH2,

-                   'pkg_version': '1.2', 'git_hash': '124', 'repo_name': 'foo'})

+             mock.call({'build_id': 125, 'pkg_name': 'foo', 'branch': self.BRANCH,

+                        'pkg_version': '1.2', 'git_hash': '123', 'repo_name': 'foo'}),

+             mock.call({'build_id': 125, 'pkg_name': 'foo', 'branch': self.BRANCH2,

+                        'pkg_version': '1.2', 'git_hash': '124', 'repo_name': 'foo'})

          ]))

  

      def test_run(self, mc_time, mc_worker):

<a class="font-weight-bold ml-2" href="/copr/copr/blob/15b0f4eff532eff0a17af9f227a5a1d4258b3565/f/dist-git/tests/test_package_import.py" title="View file as of 15b0f4e">dist-git/tests/test_package_import.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+4</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-5</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/15b0f4eff532eff0a17af9f227a5a1d4258b3565/f/dist-git/tests/test_package_import.py" title="View file as of 15b0f4e"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_23"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -4,7 +4,6 @@ 

  import pytest

  

  from pyrpkg import rpkgError

- from mock import call

  from munch import Munch

  

  from base import Base
@@ -123,13 +122,13 @@ 

          branches = ['f25', 'f26']

          setup_git_repo(reponame, branches)

          assert mc_subprocess_check_output.has_calls([

-             call(['/usr/share/dist-git/setup_git_package', 'foo']),

-             call(['/usr/share/dist-git/mkbranch', 'f25', 'foo']),

-             call(['/usr/share/dist-git/mkbranch', 'f26', 'foo']),

+             mock.call(['/usr/share/dist-git/setup_git_package', 'foo']),

+             mock.call(['/usr/share/dist-git/mkbranch', 'f25', 'foo']),

+             mock.call(['/usr/share/dist-git/mkbranch', 'f26', 'foo']),

          ])

  

      def refresh_cgit_listing(self, mc_subprocess_check_output):

          refresh_cgit_listing(self.opts)

          assert mc_subprocess_check_output.has_calls([

-             call(["/usr/share/copr/dist_git/bin/cgit_pkg_list", self.opts.cgit_pkg_list_location])

+             mock.call(["/usr/share/copr/dist_git/bin/cgit_pkg_list", self.opts.cgit_pkg_list_location])

          ])

<a class="font-weight-bold ml-2" href="/copr/copr/blob/8e5ad8180f8d180eb33d2db99262e0accaf51f51/f/frontend/copr-frontend.spec" title="View file as of 8e5ad81">frontend/copr-frontend.spec</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-1</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/8e5ad8180f8d180eb33d2db99262e0accaf51f51/f/frontend/copr-frontend.spec" title="View file as of 8e5ad81"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_24"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -80,7 +80,6 @@ 

  BuildRequires: python3-redis

  BuildRequires: python3-dateutil

  BuildRequires: python3-pytest

- BuildRequires: python3-mock

  BuildRequires: python3-decorator

  BuildRequires: python3-markdown

  BuildRequires: python3-pytz

<a class="font-weight-bold ml-2" href="/copr/copr/blob/fadde39f9f87ed79e9d004a288ab69f079b6f055/f/frontend/coprs_frontend/coprs/rest_api/exceptions.py" title="View file as of fadde39">frontend/coprs_frontend/coprs/rest_api/exceptions.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-6</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/fadde39f9f87ed79e9d004a288ab69f079b6f055/f/frontend/coprs_frontend/coprs/rest_api/exceptions.py" title="View file as of fadde39"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_25"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -1,6 +1,4 @@ 

  # coding: utf-8

- import six

- 

  

  class ApiError(Exception):

      def __init__(self, code, msg, data=None, **kwargs):
@@ -15,10 +13,6 @@ 

      def __str__(self):

          return str(self.data)

  

-     if six.PY2:

-         def __unicode__(self):

-             return unicode(self.data)

- 

  

  class AuthFailed(ApiError):

      def __init__(self, msg=None, data=None, **kwargs):

<a class="font-weight-bold ml-2" href="/copr/copr/blob/94d261a0dc56ab987bcb4f14de57c69f7e927cc5/f/frontend/coprs_frontend/tests/coprs_test_case.py" title="View file as of 94d261a">frontend/coprs_frontend/tests/coprs_test_case.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+2</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-7</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/94d261a0dc56ab987bcb4f14de57c69f7e927cc5/f/frontend/coprs_frontend/tests/coprs_test_case.py" title="View file as of 94d261a"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_26"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -18,15 +18,10 @@ 

  from coprs import models

  from coprs.logic.coprs_logic import BranchesLogic

  

- import six

  from coprs.helpers import StatusEnum

  

- if six.PY3:

-     from unittest import mock

-     from unittest.mock import MagicMock

- else:

-     import mock

-     from mock import MagicMock

+ from unittest import mock

+ from unittest.mock import MagicMock

  

  

  class CoprsTestCase(object):

<a class="font-weight-bold ml-2" href="/copr/copr/blob/7727f9d6e25c606e8f181b2aa23f2a8556de0dcd/f/frontend/coprs_frontend/tests/test_helpers.py" title="View file as of 7727f9d">frontend/coprs_frontend/tests/test_helpers.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+1</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-6</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/7727f9d6e25c606e8f181b2aa23f2a8556de0dcd/f/frontend/coprs_frontend/tests/test_helpers.py" title="View file as of 7727f9d"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_27"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -1,11 +1,6 @@ 

  from copy import deepcopy

+ from unittest import mock

  from flask import Flask, current_app

- import six

- 

- if six.PY3:

-     from unittest import mock

- else:

-     import mock

  

  from coprs import app

  from coprs.helpers import parse_package_name, generate_repo_url, \

<a class="font-weight-bold ml-2" href="/copr/copr/blob/d73f7cd7f364d070af0f967b311d7066e9ebfc8a/f/frontend/coprs_frontend/tests/test_logic/test_complex_logic.py" title="View file as of d73f7cd">frontend/coprs_frontend/tests/test_logic/test_complex_logic.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+1</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-1</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/d73f7cd7f364d070af0f967b311d7066e9ebfc8a/f/frontend/coprs_frontend/tests/test_logic/test_complex_logic.py" title="View file as of d73f7cd"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_28"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -1,5 +1,5 @@ 

  import json

- import mock

+ from unittest import mock

  

  from coprs.helpers import ActionTypeEnum

  from coprs.logic.actions_logic import ActionsLogic

<a class="font-weight-bold ml-2" href="/copr/copr/blob/4c4978d6a0109578517283ecdd7aaacab4e77612/f/frontend/coprs_frontend/tests/test_logic/test_modules_logic.py" title="View file as of 4c4978d">frontend/coprs_frontend/tests/test_logic/test_modules_logic.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+6</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-5</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/4c4978d6a0109578517283ecdd7aaacab4e77612/f/frontend/coprs_frontend/tests/test_logic/test_modules_logic.py" title="View file as of 4c4978d"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_29"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -1,6 +1,7 @@ 

  import yaml

  from munch import Munch

- from mock import patch, ANY

+ from unittest import mock

+ 

  from tests.coprs_test_case import CoprsTestCase

  from coprs.logic.modules_logic import ModuleBuildFacade, ModulemdGenerator, MBSResponse, MBSProxy

  from modulemd.components.rpm import ModuleComponentRPM
@@ -84,7 +85,7 @@ 

          assert component.name == self.b1.package_name

          assert component.rationale == "A reason why package is in the module"

  

-         with patch("coprs.app.config", self.config):

+         with mock.patch("coprs.app.config", self.config):

              assert component.repository.startswith("http://distgiturl.org")

              assert component.repository.endswith(".git")

              assert chroot.dist_git_url.startswith(component.repository)
@@ -96,9 +97,9 @@ 

          builds = [self.b1.id, self.b3.id]

          generator = ModulemdGenerator(config=self.config)

  

-         with patch("coprs.logic.modules_logic.ModulemdGenerator.add_component") as add_component:

+         with mock.patch("coprs.logic.modules_logic.ModulemdGenerator.add_component") as add_component:

              generator.add_components(packages, filter_packages, builds)

-             add_component.assert_called_with(self.p2.name, self.b3, self.b3.build_chroots[-1], ANY, 1)

+             add_component.assert_called_with(self.p2.name, self.b3, self.b3.build_chroots[-1], mock.ANY, 1)

              assert add_component.call_count == 2

  

      def test_components_different_chroots(self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
@@ -146,7 +147,7 @@ 

  

  class TestMBSProxy(CoprsTestCase):

  

-     @patch("requests.post")

+     @mock.patch("requests.post")

      def test_post(self, post_mock):

          url = "http://some-module-build-service.org"

          proxy = MBSProxy(url)

<a class="font-weight-bold ml-2" href="/copr/copr/blob/32db961a0bd02ec9f879d30a2a7abd7f3940ee85/f/frontend/coprs_frontend/tests/test_models.py" title="View file as of 32db961">frontend/coprs_frontend/tests/test_models.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+1</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-6</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/32db961a0bd02ec9f879d30a2a7abd7f3940ee85/f/frontend/coprs_frontend/tests/test_models.py" title="View file as of 32db961"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_30"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -1,10 +1,5 @@ 

  from copy import deepcopy

- import six

- 

- if six.PY3:

-     from unittest import mock

- else:

-     import mock

+ from unittest import mock

  

  from tests.coprs_test_case import CoprsTestCase

  

<a class="font-weight-bold ml-2" href="/copr/copr/blob/e9d5c8ff0e9501ce1f0098005663ee3217c85c9a/f/frontend/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py" title="View file as of e9d5c8f">frontend/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+1</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-2</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/e9d5c8ff0e9501ce1f0098005663ee3217c85c9a/f/frontend/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py" title="View file as of e9d5c8f"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_31"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -2,8 +2,7 @@ 

  import flask

  import pytest

  

- import mock

- 

+ from unittest import mock

  

  from coprs import models

  from coprs.helpers import ActionTypeEnum

<a class="font-weight-bold ml-2" href="/copr/copr/blob/ff8c6ec6608482f8761d5ccc815f642535101b18/f/keygen/copr-keygen.spec" title="View file as of ff8c6ec">keygen/copr-keygen.spec</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-4</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/ff8c6ec6608482f8761d5ccc815f642535101b18/f/keygen/copr-keygen.spec" title="View file as of ff8c6ec"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_32"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -1,7 +1,6 @@ 

  %global with_test 1

  %if 0%{?rhel} < 7 && 0%{?rhel} > 0

  %global _pkgdocdir %{_docdir}/%{name}-%{version}

- %global __python2 %{__python}

  %endif

  

  Name:       {{{ git_dir_name }}}
@@ -30,7 +29,6 @@ 

  # for tests

  BuildRequires: python3-pytest

  BuildRequires: python3-pytest-cov

- BuildRequires: python3-mock

  

  Requires:   haveged

  Requires:   gnupg2
@@ -47,7 +45,6 @@ 

  # tests

  Requires:   python3-pytest

  Requires:   python3-pytest-cov

- Requires:   python3-mock

  

  # scriptlets

  Requires(post): initscripts
@@ -68,7 +65,6 @@ 

  

  BuildRequires: python3-devel

  BuildRequires: python3-setuptools

- BuildRequires: python3-mock

  BuildRequires: python3-requests

  BuildRequires: python3-six

  BuildRequires: python3-flask

<a class="font-weight-bold ml-2" href="/copr/copr/blob/ea3d2e860fe41169e864c2d8a42c8fe489668b0e/f/python/copr/test/test_client.py" title="View file as of ea3d2e8">python/copr/test/test_client.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+6</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-1</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/ea3d2e860fe41169e864c2d8a42c8fe489668b0e/f/python/copr/test/test_client.py" title="View file as of ea3d2e8"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_33"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -1,10 +1,15 @@ 

  import os

  

- import mock

  from requests.models import Response

  

  from copr import CoprClient

  

+ try:

+      from unittest import mock

+ except ImportError:

+      # Python 2 version depends on mock

+      import mock

+ 

  path = os.path.abspath(__file__)

  dir_path = os.path.dirname(path)

  resource_location = os.path.join(dir_path, "resources")

<a class="font-weight-bold ml-2" href="/copr/copr/blob/1c3a375917b931048ae3e248b6dd2c2027f57d33/f/python/python-copr.spec" title="View file as of 1c3a375">python/python-copr.spec</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-1</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/1c3a375917b931048ae3e248b6dd2c2027f57d33/f/python/python-copr.spec" title="View file as of 1c3a375"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_34"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -102,7 +102,6 @@ 

  BuildRequires: python3-devel

  BuildRequires: python3-setuptools

  BuildRequires: python3-pytest

- BuildRequires: python3-mock

  BuildRequires: python3-requests

  BuildRequires: python3-requests-toolbelt

  BuildRequires: python3-marshmallow

<a class="font-weight-bold ml-2" href="/copr/copr/blob/95be90c59be0b1ecf63e3eb4cc6fa379af269885/f/rpmbuild/copr-rpmbuild.spec" title="View file as of 95be90c">rpmbuild/copr-rpmbuild.spec</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+15</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-1</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/95be90c59be0b1ecf63e3eb4cc6fa379af269885/f/rpmbuild/copr-rpmbuild.spec" title="View file as of 95be90c"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_35"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -18,6 +18,7 @@ 

  Release: 1%{?dist}

  URL: https://pagure.io/copr/copr

  License: GPLv2+

+ BuildArch: noarch

  

  # Source is created by:

  # git clone https://pagure.io/copr/copr.git
@@ -26,16 +27,26 @@ 

  # rpkg spec --sources

  Source0: {{{ git_dir_pack }}}

  

- BuildArch: noarch

  BuildRequires: %python-devel

  BuildRequires: %rpm_python

  BuildRequires: asciidoc

  BuildRequires: %python-setuptools

+ BuildRequires: %python-pytest

+ BuildRequires: %python_pfx-munch

+ BuildRequires: %python-requests

+ BuildRequires: %python_pfx-jinja2

+ BuildRequires: %python-configparser

+ 

+ %if %{?python} == "python2"

+ BuildRequires: python2-mock

+ %endif

+ 

  Requires: %python

  Requires: %python_pfx-jinja2

  Requires: %python_pfx-munch

  Requires: %python-configparser

  Requires: %python-simplejson

+ Requires: %python-requests

  

  Requires: mock

  Requires: git
@@ -54,6 +65,9 @@ 

  %prep

  %setup -q

  

+ %check

+ PYTHON=%{python} ./run_tests.sh

+ 

  %build

  name="%{name}" version="%{version}" summary="%{summary}" %python_build

  a2x -d manpage -f manpage man/copr-rpmbuild.1.asciidoc

<a class="font-weight-bold ml-2" href="/copr/copr/blob/231c210328a3c26e5388c8d089bdc9eb6f55f10a/f/rpmbuild/copr_rpmbuild/builders/mock.py" title="View file as of 231c210">rpmbuild/copr_rpmbuild/builders/mock.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+2</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-2</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/231c210328a3c26e5388c8d089bdc9eb6f55f10a/f/rpmbuild/copr_rpmbuild/builders/mock.py" title="View file as of 231c210"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_36"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -45,8 +45,8 @@ 

          self.use_bootstrap_container = task.get("use_bootstrap_container")

          self.pkg_manager_conf = "dnf" if "custom-1" in task.get("chroot") else "yum"

          self.timeout = task.get("timeout", 3600)

-         self.with_opts = task.get("with_opts")

-         self.without_opts = task.get("without_opts")

+         self.with_opts = task.get("with_opts", [])

+         self.without_opts = task.get("without_opts", [])

          self.sourcedir = sourcedir

          self.resultdir = resultdir

          self.config = config

<a class="font-weight-bold ml-2" href="/copr/copr/blob/3ee230140f012fe8da464802c86823f1d9162dfc/f/rpmbuild/run_tests.sh" title="View file as of 3ee2301">rpmbuild/run_tests.sh</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+4</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-1</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/3ee230140f012fe8da464802c86823f1d9162dfc/f/rpmbuild/run_tests.sh" title="View file as of 3ee2301"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_37"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -1,2 +1,5 @@ 

  #!/bin/sh

- python3 -m pytest tests -s $@

+ 

+ path="${1:-tests}"

+ 

+ PYTHONPATH=".:$PYTHONPATH" "${PYTHON:-python3}" -m pytest -s "$path"

<a class="font-weight-bold ml-2" href="/copr/copr/blob/0eda85d064200f5df0062adb5b5a9a4d94e5b3e1/f/rpmbuild/tests/__init__.py" title="View file as of 0eda85d">rpmbuild/tests/__init__.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+2</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-2</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/0eda85d064200f5df0062adb5b5a9a4d94e5b3e1/f/rpmbuild/tests/__init__.py" title="View file as of 0eda85d"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_38"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -2,7 +2,7 @@ 

  import tempfile

  import unittest

  

- from ..copr_rpmbuild import helpers

+ from copr_rpmbuild import helpers

  

  CONFIG = """

  [main]
@@ -35,7 +35,7 @@ 

  

      def read_config_data(self, config_data):

          fd, config_path = tempfile.mkstemp()

-         f = open(fd, 'w')

+         f = open(config_path, 'w')

          f.write(config_data)

          f.close()

          return config_path, helpers.read_config(config_path)

<a class="font-weight-bold ml-2" href="/copr/copr/blob/19aa446afb95a898790d352f5187da0c5978d1d0/f/rpmbuild/tests/test_base.py" title="View file as of 19aa446">rpmbuild/tests/test_base.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+12</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-10</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/19aa446afb95a898790d352f5187da0c5978d1d0/f/rpmbuild/tests/test_base.py" title="View file as of 19aa446"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_39"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -1,10 +1,13 @@ 

- import mock

- from mock import MagicMock

- from mock import call

- 

- from ..copr_rpmbuild.providers.base import Provider

+ from copr_rpmbuild.providers.base import Provider

  from . import TestCase

  

+ try:

+      from unittest import mock

+      builtins = 'builtins'

+ except ImportError:

+      # Python 2 version depends on mock

+      import mock

+      builtins = '__builtin__'

  

  class TestProvider(TestCase):

      def setUp(self):
@@ -12,16 +15,15 @@ 

          self.source_json = {}

          self.resultdir = "/path/to/resultdir"

  

-     @mock.patch('builtins.open', new_callable=mock.mock_open())

+     @mock.patch('{}.open'.format(builtins), new_callable=mock.mock_open())

      def test_create_rpmmacros(self, mock_open):

          provider = Provider(self.source_json, self.resultdir, self.config)

-         rpmmacros = MagicMock()

+         rpmmacros = mock.MagicMock()

          mock_open.return_value = rpmmacros

          provider.create_rpmmacros()

          mock_open.assert_called_with("{}/.rpmmacros".format(provider.workdir), "w")

          calls = [

-             call.__enter__().write('%_disable_source_fetch 0\n'),

-             call.__enter__().write('%__urlhelper_localopts --proto -all,+https,+ftps\n'),

+             mock.call.__enter__().write('%_disable_source_fetch 0\n'),

+             mock.call.__enter__().write('%__urlhelper_localopts --proto -all,+https,+ftps\n'),

          ]

          rpmmacros.assert_has_calls(calls, any_order=True)

- 

<a class="font-weight-bold ml-2" href="/copr/copr/blob/5c0e3d24e9484d3647e73e5c7688314f323093af/f/rpmbuild/tests/test_helpers.py" title="View file as of 5c0e3d2">rpmbuild/tests/test_helpers.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+7</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-5</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/5c0e3d24e9484d3647e73e5c7688314f323093af/f/rpmbuild/tests/test_helpers.py" title="View file as of 5c0e3d2"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_40"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -1,8 +1,9 @@ 

  import unittest

  import tempfile

+ import shutil

  import os

  

- from ..copr_rpmbuild.helpers import string2list, locate_srpm

+ from copr_rpmbuild.helpers import string2list, locate_srpm

  

  class TestHelpers(unittest.TestCase):

      def test_string2list(self):
@@ -13,7 +14,8 @@ 

          self.assertEqual(string2list(',,foo\tbar\tbaz'), ['foo', 'bar', 'baz'])

  

      def test_locate_srpm(self):

-         with tempfile.TemporaryDirectory() as tmpdir:

-             srpm_path = os.path.join(tmpdir, "dummy.src.rpm")

-             open(srpm_path, "w").close()

-             self.assertEqual(srpm_path, locate_srpm(tmpdir))

+         tmpdir = tempfile.mkdtemp()

+         srpm_path = os.path.join(tmpdir, "dummy.src.rpm")

+         open(srpm_path, "w").close()

+         self.assertEqual(srpm_path, locate_srpm(tmpdir))

+         shutil.rmtree(tmpdir)

<a class="font-weight-bold ml-2" href="/copr/copr/blob/6daae4fa2371a4bbe8658dd0903503a276881743/f/rpmbuild/tests/test_mock.py" title="View file as of 6daae4f">rpmbuild/tests/test_mock.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+19</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-9</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/6daae4fa2371a4bbe8658dd0903503a276881743/f/rpmbuild/tests/test_mock.py" title="View file as of 6daae4f"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_41"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -1,13 +1,19 @@ 

  import re

  import unittest

- import mock

  import configparser

- from os.path import realpath, dirname

- from ..copr_rpmbuild.builders.mock import MockBuilder

  import subprocess

  import datetime

+ from os.path import realpath, dirname

+ 

+ from copr_rpmbuild.builders.mock import MockBuilder

  

- from unittest.mock import MagicMock

+ try:

+      from unittest import mock

+      builtins = 'builtins'

+ except ImportError:

+      # Python 2 version depends on mock

+      import mock

+      builtins = '__builtin__'

  

  class TestMockBuilder(unittest.TestCase):

      def setUp(self):
@@ -35,6 +41,8 @@ 

              "task_id": "10-fedora-24-x86_64",

              "timeout": 21600,

              "use_bootstrap_container": False,

+             "with_opts": [],

+             "without_opts": [],

          }

          self.sourcedir = "/path/to/sourcedir"

          self.resultdir = "/path/to/resultdir"
@@ -71,12 +79,12 @@ 

          self.assertEqual(config_opts["use_bootstrap_container"], False)

          self.assertEqual(config_opts["yum.conf"], [])

  

-     @mock.patch("rpmbuild.copr_rpmbuild.builders.mock.get_mock_uniqueext")

-     @mock.patch("rpmbuild.copr_rpmbuild.builders.mock.subprocess.Popen")

+     @mock.patch("copr_rpmbuild.builders.mock.get_mock_uniqueext")

+     @mock.patch("copr_rpmbuild.builders.mock.GentlyTimeoutedPopen")

      def test_produce_rpm(self, popen_mock, get_mock_uniqueext_mock):

          builder = MockBuilder(self.task, self.sourcedir, self.resultdir, self.config)

          get_mock_uniqueext_mock.return_value = '2'

-         process = MagicMock(returncode=0)

+         process = mock.MagicMock(returncode=0)

          popen_mock.return_value = process

          builder.produce_rpm("/path/to/pkg.src.rpm", "/path/to/configs", "/path/to/results")

          assert_cmd = ['unbuffer', '/usr/bin/mock',
@@ -85,9 +93,11 @@ 

                        '--resultdir', '/path/to/results',

                        '--uniqueext', '2',

                        '-r', 'child']

-         popen_mock.assert_called_with(assert_cmd, stdin=subprocess.PIPE, preexec_fn=builder.preexec_fn_build_stream)

+         popen_mock.assert_called_with(assert_cmd, stdin=subprocess.PIPE,

+                                       preexec_fn=builder.preexec_fn_build_stream,

+                                       timeout=21600)

  

-     @mock.patch('builtins.open', new_callable=mock.mock_open())

+     @mock.patch('{}.open'.format(builtins), new_callable=mock.mock_open())

      def test_touch_success_file(self, mock_open):

          builder = MockBuilder(self.task, self.sourcedir, self.resultdir, self.config)

          builder.touch_success_file()

<a class="font-weight-bold ml-2" href="/copr/copr/blob/cec5166d03bdff1b6e54f03dc4250ab03e376a18/f/rpmbuild/tests/test_providers.py" title="View file as of cec5166">rpmbuild/tests/test_providers.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+3</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-3</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/cec5166d03bdff1b6e54f03dc4250ab03e376a18/f/rpmbuild/tests/test_providers.py" title="View file as of cec5166"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_42"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -1,8 +1,8 @@ 

  import unittest

- from ..copr_rpmbuild.providers import (factory, RubyGemsProvider, PyPIProvider,

-                                        SpecUrlProvider)

+ from copr_rpmbuild.providers import (factory, RubyGemsProvider, PyPIProvider,

+                                      SpecUrlProvider)

  

- from ..copr_rpmbuild.helpers import SourceType

+ from copr_rpmbuild.helpers import SourceType

  

  

  class TestProvidersFactory(unittest.TestCase):

<a class="font-weight-bold ml-2" href="/copr/copr/blob/068e918a587e1f2f8310d7c4dac419ceae3f0e90/f/rpmbuild/tests/test_pypi.py" title="View file as of 068e918">rpmbuild/tests/test_pypi.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+11</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-5</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/068e918a587e1f2f8310d7c4dac419ceae3f0e90/f/rpmbuild/tests/test_pypi.py" title="View file as of 068e918"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_43"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -1,8 +1,14 @@ 

- import mock

- import unittest

- from ..copr_rpmbuild.providers.pypi import PyPIProvider

+ from copr_rpmbuild.providers.pypi import PyPIProvider

  from . import TestCase

  

+ try:

+      from unittest import mock

+      builtins = 'builtins'

+ except ImportError:

+      # Python 2 version depends on mock

+      import mock

+      builtins = '__builtin__'

+ 

  

  class TestPyPIProvider(TestCase):

      def setUp(self):
@@ -18,8 +24,8 @@ 

         self.assertEqual(provider.pypi_package_name, "motionpaint")

         self.assertEqual(provider.python_versions, [2, 3])

  

-     @mock.patch("rpmbuild.copr_rpmbuild.providers.pypi.run_cmd")

-     @mock.patch("builtins.open")

+     @mock.patch("copr_rpmbuild.providers.pypi.run_cmd")

+     @mock.patch("{}.open".format(builtins))

      def test_produce_srpm(self, mock_open, run_cmd):

          provider = PyPIProvider(self.source_json, "/some/tmp/directory", self.config)

          provider.produce_srpm()

<a class="font-weight-bold ml-2" href="/copr/copr/blob/1b509075bed9d6a6ace3ea2eec08cf3e4b8ccd39/f/rpmbuild/tests/test_rubygems.py" title="View file as of 1b50907">rpmbuild/tests/test_rubygems.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+13</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-7</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/1b509075bed9d6a6ace3ea2eec08cf3e4b8ccd39/f/rpmbuild/tests/test_rubygems.py" title="View file as of 1b50907"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_44"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -1,9 +1,15 @@ 

- import mock

- import unittest

  from munch import Munch

- from ..copr_rpmbuild.providers.rubygems import RubyGemsProvider

+ from copr_rpmbuild.providers.rubygems import RubyGemsProvider

  from . import TestCase

  

+ try:

+      from unittest import mock

+      builtins = 'builtins'

+ except ImportError:

+      # Python 2 version depends on mock

+      import mock

+      builtins = '__builtin__'

+ 

  

  class TestRubyGemsProvider(TestCase):

      def setUp(self):
@@ -15,16 +21,16 @@ 

          provider = RubyGemsProvider(self.source_json, self.resultdir, self.config)

          self.assertEqual(provider.gem_name, "A_123")

  

-     @mock.patch("rpmbuild.copr_rpmbuild.providers.rubygems.run_cmd")

-     @mock.patch("builtins.open")

+     @mock.patch("copr_rpmbuild.providers.rubygems.run_cmd")

+     @mock.patch("{}.open".format(builtins))

      def test_produce_srpm(self, mock_open, run_cmd):

          provider = RubyGemsProvider(self.source_json, self.resultdir, self.config)

          provider.produce_srpm()

          assert_cmd = ["gem2rpm", "A_123", "--srpm", "-C", "/path/to/resultdir", "--fetch"]

          run_cmd.assert_called_with(assert_cmd)

  

-     @mock.patch("rpmbuild.copr_rpmbuild.providers.rubygems.run_cmd")

-     @mock.patch("builtins.open")

+     @mock.patch("copr_rpmbuild.providers.rubygems.run_cmd")

+     @mock.patch("{}.open".format(builtins))

      def test_empty_license(self, mock_open, run_cmd):

          stderr = ("error: line 8: Empty tag: License:"

                    "Command failed: rpmbuild -bs --nodeps --define '_sourcedir /tmp/gem2rpm-foo-20170905-3367-c2flks'"

<a class="font-weight-bold ml-2" href="/copr/copr/blob/84e9e3a40fa8a63e6dfc66a510de05e8431e422e/f/rpmbuild/tests/test_scm.py" title="View file as of 84e9e3a">rpmbuild/tests/test_scm.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+12</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-9</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/84e9e3a40fa8a63e6dfc66a510de05e8431e422e/f/rpmbuild/tests/test_scm.py" title="View file as of 84e9e3a"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_45"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -1,14 +1,17 @@ 

- import mock

- import unittest

  import tempfile

  import os

  import configparser

  import shutil

- from ..copr_rpmbuild.providers.scm import ScmProvider

- from ..copr_rpmbuild.helpers import read_config

+ 

+ from copr_rpmbuild.providers.scm import ScmProvider

+ from copr_rpmbuild.helpers import read_config

  from . import TestCase

  

- from mock import patch, MagicMock

+ try:

+      from unittest import mock

+ except ImportError:

+      # Python 2 version depends on mock

+      import mock

  

  RPKG_CONF_JINJA = """

  [rpkg]
@@ -62,7 +65,7 @@ 

          source_json = self.source_json.copy()

          source_json["clone_url"] = "http://copr-dist-git.fedorainfracloud.org/git/clime/project/pkg.git"

  

-         with patch("rpmbuild.copr_rpmbuild.providers.scm.CONF_DIRS", new=[rpkg_tmpdir]):

+         with mock.patch("copr_rpmbuild.providers.scm.CONF_DIRS", new=[rpkg_tmpdir]):

              provider = ScmProvider(source_json, self.resultdir, self.config)

              rpkg_config_path = provider.generate_rpkg_config()

  
@@ -74,7 +77,7 @@ 

  

          source_json["clone_url"] = "http://unknownurl/git/clime/project/pkg.git"

  

-         with patch("rpmbuild.copr_rpmbuild.providers.scm.CONF_DIRS", new=[rpkg_tmpdir]):

+         with mock.patch("copr_rpmbuild.providers.scm.CONF_DIRS", new=[rpkg_tmpdir]):

              provider = ScmProvider(source_json, self.resultdir, self.config)

              rpkg_config_path = provider.generate_rpkg_config()

              self.assertEqual(rpkg_config_path, "/etc/rpkg.conf")
@@ -83,7 +86,7 @@ 

  

      def test_get_rpkg_command(self):

          provider = ScmProvider(self.source_json, self.resultdir, self.config)

-         provider.generate_rpkg_config = MagicMock(return_value="/etc/rpkg.conf")

+         provider.generate_rpkg_config = mock.MagicMock(return_value="/etc/rpkg.conf")

          assert_cmd = ["rpkg", "-C", "/etc/rpkg.conf", "srpm",

                        "--outdir", self.resultdir, "--spec", provider.spec_path]

          self.assertEqual(provider.get_rpkg_command(), assert_cmd)
@@ -98,7 +101,7 @@ 

          assert_cmd = ["tito", "build", "--test", "--srpm", "--output", self.resultdir]

          self.assertEqual(provider.get_tito_test_command(), assert_cmd)

  

-     @mock.patch("rpmbuild.copr_rpmbuild.providers.scm.get_mock_uniqueext")

+     @mock.patch("copr_rpmbuild.providers.scm.get_mock_uniqueext")

      def test_get_make_srpm_command(self, get_mock_uniqueext_mock):

          get_mock_uniqueext_mock.return_value = '2'

          provider = ScmProvider(self.source_json, self.resultdir, self.config)

<a class="font-weight-bold ml-2" href="/copr/copr/blob/088f3e52254cebe34d292ddc58f1e2566b76478a/f/rpmbuild/tests/test_spec.py" title="View file as of 088f3e5">rpmbuild/tests/test_spec.py</a>
<div class="btn btn-outline-secondary disabled opacity-100 border-0 font-weight-bold"> file modified </div> <div class="btn-group"> <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+13</span> <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-6</span> </div> <a class="btn btn-outline-primary btn-sm ml-2" href="/copr/copr/blob/088f3e52254cebe34d292ddc58f1e2566b76478a/f/rpmbuild/tests/test_spec.py" title="View file as of 088f3e5"> <i class="fa fa-file-code-o fa-fw"></i> </a> <a class="btn btn-sm btn-outline-primary diffhighlightcollapse ml-2 pointer" data-toggle="collapse" data-target="#diffhighlight_46"> <i class="fa fa-fw fa-caret-up"></i> </a>
@@ -1,9 +1,16 @@ 

- import mock

- import unittest

  import configparser

- from ..copr_rpmbuild.providers.spec import SpecUrlProvider

+ 

+ from copr_rpmbuild.providers.spec import SpecUrlProvider

  from . import TestCase

  

+ try:

+      from unittest import mock

+      builtins = 'builtins'

+ except ImportError:

+      # Python 2 version depends on mock

+      import mock

+      builtins = '__builtin__'

+ 

  

  class TestSpecUrlProvider(TestCase):

      def setUp(self):
@@ -16,8 +23,8 @@ 

          self.assertEqual(provider.url, "http://foo.ex/somepackage.spec")

  

      @mock.patch('requests.get')

-     @mock.patch("rpmbuild.copr_rpmbuild.providers.spec.run_cmd")

-     @mock.patch('builtins.open', new_callable=mock.mock_open())

+     @mock.patch("copr_rpmbuild.providers.spec.run_cmd")

+     @mock.patch('{}.open'.format(builtins), new_callable=mock.mock_open())

      def test_produce_srpm(self, mock_open, run_cmd, mock_get):

          provider = SpecUrlProvider(self.source_json, self.resultdir, self.config)

          provider.produce_srpm()
@@ -26,7 +33,7 @@ 

                                     cwd=provider.workdir)

  

      @mock.patch('requests.get')

-     @mock.patch('builtins.open', new_callable=mock.mock_open())

+     @mock.patch('{}.open'.format(builtins), new_callable=mock.mock_open())

      def test_save_spec(self, mock_open, mock_get):

          provider = SpecUrlProvider(self.source_json, self.resultdir, self.config)

          provider.save_spec()

As suggested in https://lists.fedoraproject.org/archives/list/copr-devel@lists.fedorahosted.org/thread/LNQZYFZJAWWRYN2PH7BSD6LXX3XUMGPG/, we should get rid of python3-mock and use unittest native python3 module. Only for python2 (copr-cli, python-copr, copr-rpmbuild), we should employ python2-mock, which is supposed to backport functionality from python3's unittest.mock into python2. Basically, we should be doing something like:

 try: 
     from unittest import mock 
 except ImportError: 
     # Python 2 version depends on mock 
     import mock

in our tests that should be run under python2 as well as well as python3. This is what this PR does.

I also needed to fix copr-rpmbuild tests under EPEL7 so that I could verify this change work. I enabled running the tests during build in %check phase.

1 new commit added

  • fix missing double-quotes in run_test.sh
3 years ago

Pull-Request has been merged by clime

3 years ago
Metadata
Changes Summary 46
+0 -1
file changed
backend/copr-backend.spec
+2 -2
file changed
backend/tests/daemons/test_backend.py
+2 -2
file changed
backend/tests/daemons/test_dispatcher.py
+2 -2
file changed
backend/tests/daemons/test_job_grab.py
+3 -3
file changed
backend/tests/daemons/test_log.py
+2 -2
file changed
backend/tests/daemons/test_vm_master.py
+2 -2
file changed
backend/tests/mockremote/test_builder.py
+2 -2
file changed
backend/tests/mockremote/test_mockremote.py
+2 -2
file changed
backend/tests/run/test_copr_prune_results.py
+2 -2
file changed
backend/tests/test_action.py
+2 -2
file changed
backend/tests/test_createrepo.py
+2 -2
file changed
backend/tests/test_frontend.py
+2 -2
file changed
backend/tests/test_sign.py
+2 -2
file changed
backend/tests/vm_manager/test_check.py
+2 -2
file changed
backend/tests/vm_manager/test_event_handle.py
+1 -1
file changed
backend/tests/vm_manager/test_executor.py
+2 -2
file changed
backend/tests/vm_manager/test_manager.py
+2 -2
file changed
backend/tests/vm_manager/test_spawn.py
+2 -2
file changed
backend/tests/vm_manager/test_terminate.py
+0 -1
file changed
dist-git/copr-dist-git.spec
+2 -1
file changed
dist-git/tests/test_crazy_merging.py
+4 -6
file changed
dist-git/tests/test_importer.py
+4 -5
file changed
dist-git/tests/test_package_import.py
+0 -1
file changed
frontend/copr-frontend.spec
+0 -6
file changed
frontend/coprs_frontend/coprs/rest_api/exceptions.py
+2 -7
file changed
frontend/coprs_frontend/tests/coprs_test_case.py
+1 -6
file changed
frontend/coprs_frontend/tests/test_helpers.py
+1 -1
file changed
frontend/coprs_frontend/tests/test_logic/test_complex_logic.py
+6 -5
file changed
frontend/coprs_frontend/tests/test_logic/test_modules_logic.py
+1 -6
file changed
frontend/coprs_frontend/tests/test_models.py
+1 -2
file changed
frontend/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py
+0 -4
file changed
keygen/copr-keygen.spec
+6 -1
file changed
python/copr/test/test_client.py
+0 -1
file changed
python/python-copr.spec
+15 -1
file changed
rpmbuild/copr-rpmbuild.spec
+2 -2
file changed
rpmbuild/copr_rpmbuild/builders/mock.py
+4 -1
file changed
rpmbuild/run_tests.sh
+2 -2
file changed
rpmbuild/tests/__init__.py
+12 -10
file changed
rpmbuild/tests/test_base.py
+7 -5
file changed
rpmbuild/tests/test_helpers.py
+19 -9
file changed
rpmbuild/tests/test_mock.py
+3 -3
file changed
rpmbuild/tests/test_providers.py
+11 -5
file changed
rpmbuild/tests/test_pypi.py
+13 -7
file changed
rpmbuild/tests/test_rubygems.py
+12 -9
file changed
rpmbuild/tests/test_scm.py
+13 -6
file changed
rpmbuild/tests/test_spec.py