tests: remove use of mocker as context-manager (#3480)

This commit is contained in:
Saugat Pachhai
2020-03-16 08:25:22 +05:45
committed by GitHub
parent e69b44d1ed
commit d2734dfe1e
4 changed files with 40 additions and 43 deletions
+9 -11
View File
@@ -22,14 +22,12 @@ def test_failed_import_url(mocker, caplog):
assert cli_args.func == CmdImportUrl
cmd = cli_args.func(cli_args)
with mocker.patch.object(
cmd.repo, "imp_url", side_effect=DvcException("error")
):
with caplog.at_level(logging.ERROR, logger="dvc"):
assert cmd.run() == 1
expected_error = (
"failed to import http://somesite.com/file_name. "
"You could also try downloading it manually, and "
"adding it with `dvc add`."
)
assert expected_error in caplog.text
mocker.patch.object(cmd.repo, "imp_url", side_effect=DvcException("error"))
with caplog.at_level(logging.ERROR, logger="dvc"):
assert cmd.run() == 1
expected_error = (
"failed to import http://somesite.com/file_name. "
"You could also try downloading it manually, and "
"adding it with `dvc add`."
)
assert expected_error in caplog.text