8000 Update references to mock in Repo tests · jhermann/github3.py@7f7901f · GitHub
[go: up one dir, main page]

Skip to content

Commit 7f7901f

Browse files
committed
Update references to mock in Repo tests
1 parent 762ad57 commit 7f7901f

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

tests/test_repos.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
import github3
33
from github3 import repos
44
from datetime import datetime
5-
from tests.utils import (BaseCase, load)
6-
try:
7-
from unittest.mock import patch, mock_open
8-
except ImportError:
9-
from mock import patch, mock_open
5+
from tests.utils import (BaseCase, load, mock)
106

117

128
class TestRepository(BaseCase):
@@ -64,8 +60,8 @@ def test_archive(self):
6460
self.request.return_value.raw.seek(0)
6561
self.request.return_value._content_consumed = False
6662

67-
o = mock_open()
68-
with patch('{0}.open'.format(__name__), o, create=True):
63+
o = mock.mock_open()
64+
with mock.patch('{0}.open'.format(__name__), o, create=True):
6965
with open('archive', 'wb+') as fd:
7066
self.repo.archive('tarball', fd)
7167

@@ -401,15 +397,15 @@ def test_create_tag(self):
401397
None, None, None, None, None)
402398

403399
self.login()
404-
with patch.object(repos.Repository, 'create_ref'):
400+
with mock.patch.object(repos.Repository, 'create_ref'):
405401
assert self.repo.create_tag(None, None, None, None,
406402
None) is None
407403
tag = self.repo.create_tag(**data)
408404
assert isinstance(tag, github3.git.Tag)
409405
assert repr(tag).startswith('<Tag')
410406
self.mock_assertions()
411407

412-
with patch.object(repos.Repository, 'create_ref') as cr:
408+
with mock.patch.object(repos.Repository, 'create_ref') as cr:
413409
self.repo.create_tag('tag', '', 'fakesha', '', '',
414410
lightweight=True)
415411
cr.assert_called_once_with('refs/tags/tag', 'fakesha')
@@ -1020,12 +1016,12 @@ def test_update_label(self):
10201016
self.not_called()
10211017

10221018
self.login()
1023-
with patch.object(repos.Repository, 'label') as l:
1019+
with mock.patch.object(repos.Repository, 'label') as l:
10241020
l.return_value = None
10251021
assert self.repo.update_label('foo', 'bar') is False
10261022
self.not_called()
10271023

1028-
with patch.object(repos.Repository, 'label') as l:
1024+
with mock.patch.object(repos.Repository, 'label') as l:
10291025
l.return_value = github3.issues.label.Label(load('label'), self.g)
10301026
assert self.repo.update_label('big_bug', 'fafafa')
10311027

0 commit comments

Comments
 (0)
0