Skip to content

Commit 2f2a116

Browse files
author
Fabio Silva
committed
Biblioteca PytestMock.
1 parent e494bc4 commit 2f2a116

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

libpythonpro_fls/tests/test_spam/test_buscar_avatar.py renamed to libpythonpro_fls/tests/test_spam/test_github_api.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44

55
from libpythonpro_fls import github_api
66

7+
78
@pytest.fixture
8-
def avatar_url():
9+
def avatar_url(mocker):
910
resp_mock = Mock()
1011
url = 'https://avatars.githubusercontent.com/u/83844802?v=4'
1112
resp_mock.json.return_value = {
1213
'login': 'fabio1008', 'id': 83844802,
1314
'avatar_url': url,
1415
}
15-
get_original = github_api.requests.get
16-
github_api.requests.get = Mock(return_value=resp_mock)
17-
yield url
18-
github_api.requests.get = get_original
16+
get_mock = mocker.patch('libpythonpro_fls.github_api.requests.get')
17+
get_mock.return_value = resp_mock
18+
return url
19+
1920

2021
def test_buscar_avatar(avatar_url):
2122
url = github_api.buscar_avatar('fabio1008')

0 commit comments

Comments
 (0)