tests: use mocker instead of unittest.mock where possible

Had the "pleasure" of finding a mocker.patch leak into other tests and one
of the suspicions is that mixing unittest.mock and mocker might be somehow
related.

In any case, we should use mocker where possible anyway.
This commit is contained in:
Ruslan Kuprieiev
2023-06-18 17:10:45 +03:00
parent b8c666b1b7
commit c827654fe7
9 changed files with 83 additions and 78 deletions
+6 -3
View File
@@ -1,5 +1,4 @@
import os
from unittest.mock import ANY
from dvc.repo.open_repo import CLONES
from dvc.repo.open_repo import _external_repo as external_repo
@@ -140,7 +139,9 @@ def test_shallow_clone_branch(erepo_dir, mocker):
with repo.dvcfs.open("file") as fd:
assert fd.read() == "branch"
clone_spy.assert_called_with(url, ANY, shallow_branch="branch", progress=ANY)
clone_spy.assert_called_with(
url, mocker.ANY, shallow_branch="branch", progress=mocker.ANY
)
path, _ = CLONES[url]
CLONES[url] = (path, True)
@@ -165,7 +166,9 @@ def test_shallow_clone_tag(erepo_dir, mocker):
with repo.dvcfs.open("file") as fd:
assert fd.read() == "foo"
clone_spy.assert_called_with(url, ANY, shallow_branch="v1", progress=ANY)
clone_spy.assert_called_with(
url, mocker.ANY, shallow_branch="v1", progress=mocker.ANY
)
path, _ = CLONES[url]
CLONES[url] = (path, True)