diff options
author | Victor Shyba <victor1984@riseup.net> | 2017-03-20 21:38:22 -0300 |
---|---|---|
committer | drebs <drebs@leap.se> | 2017-04-04 18:27:37 +0200 |
commit | 9628d5fa3ed7bdfd046aee641a8d51605c15bd71 (patch) | |
tree | 0bf27af53f2d5c183ae54e9462c151e549e8bf99 /testing/tests/blobs/test_fs_backend.py | |
parent | a7539317d4847a9eb9fe431709ddab23e54f4be3 (diff) |
[test] use mock instead of directly patching
Diffstat (limited to 'testing/tests/blobs/test_fs_backend.py')
-rw-r--r-- | testing/tests/blobs/test_fs_backend.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/testing/tests/blobs/test_fs_backend.py b/testing/tests/blobs/test_fs_backend.py index aaf5f4c3..fd38336d 100644 --- a/testing/tests/blobs/test_fs_backend.py +++ b/testing/tests/blobs/test_fs_backend.py @@ -29,8 +29,9 @@ import pytest class FilesystemBackendTestCase(unittest.TestCase): - def test_tag_header(self): - _blobs.open = lambda x: BytesIO('A' * 40 + 'B' * 16) + @mock.patch.object(_blobs, 'open') + def test_tag_header(self, open_mock): + open_mock.return_value = BytesIO('A' * 40 + 'B' * 16) expected_tag = base64.urlsafe_b64encode('B' * 16) expected_method = Mock() backend = _blobs.FilesystemBlobsBackend() @@ -39,9 +40,10 @@ class FilesystemBackendTestCase(unittest.TestCase): expected_method.assert_called_once_with('Tag', [expected_tag]) - def test_read_blob(self): + @mock.patch.object(_blobs.static, 'File') + def test_read_blob(self, file_mock): render_mock = Mock() - _blobs.static.File = Mock(return_value=render_mock) + file_mock.return_value = render_mock backend = _blobs.FilesystemBlobsBackend() request = object() backend._get_path = Mock(return_value='path') |