|
1 | | -import pytest |
| 1 | +import logging |
2 | 2 |
|
3 | | -from dvc.config import ConfigError |
4 | | -from dvc.remote.s3 import RemoteS3 |
| 3 | +import pytest |
| 4 | +from mock import patch |
| 5 | +from dvc.remote import RemoteS3 |
5 | 6 | from tests.utils import empty_caplog |
6 | 7 |
|
7 | 8 | bucket_name = "bucket-name" |
@@ -59,22 +60,23 @@ def test_grants_mutually_exclusive_acl_error(grants): |
59 | 60 | @pytest.mark.parametrize( |
60 | 61 | "default_jobs_number,expected_result", [(10, 10), (13, 12)] |
61 | 62 | ) |
62 | | -@patch("resource.getrlimit", return_value=(256, 1024)) |
63 | 63 | def test_adjust_default_jobs_number( |
64 | | - _, caplog, default_jobs_number, expected_result |
| 64 | + mocker, caplog, default_jobs_number, expected_result |
65 | 65 | ): |
66 | 66 | remote = RemoteS3(None, {}) |
67 | 67 |
|
68 | | - with empty_caplog(caplog), patch.object( |
69 | | - remote, "JOBS", default_jobs_number |
70 | | - ): |
| 68 | + mocker.patch("resource.getrlimit", return_value=(256, 1024)) |
| 69 | + mocker.patch.object(remote, "JOBS", default_jobs_number) |
| 70 | + |
| 71 | + with empty_caplog(caplog): |
71 | 72 | assert remote.adjust_jobs() == expected_result |
72 | 73 |
|
73 | 74 |
|
74 | | -@patch("resource.getrlimit", return_value=(256, 1024)) |
75 | | -def test_warn_on_too_many_jobs(_, caplog): |
| 75 | +def test_warn_on_too_many_jobs(mocker, caplog): |
76 | 76 | remote = RemoteS3(None, {}) |
77 | 77 |
|
| 78 | + mocker.patch("resource.getrlimit", return_value=(256, 1024)) |
| 79 | + |
78 | 80 | with caplog.at_level(logging.INFO, "dvc"): |
79 | 81 | assert remote.adjust_jobs(64) == 64 |
80 | 82 | assert len(caplog.messages) == 1 |
|
0 commit comments