Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8713f07

Browse files
committed
Last iteration forsigmavirus24#128 and unit test for it
1 parent27750e1 commit8713f07

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

‎github3/structs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, count, url, cls, session, params=None, etag=None):
1616
#: Class being used to cast all items to
1717
self.cls=cls
1818
#: Parameters of the query string
19-
self.params=params
19+
self.params=paramsor {}
2020
self._remove_none(self.params)
2121
# We do not set this from the parameter sent. We want this to
2222
# represent the ETag header returned by GitHub no matter what.
@@ -42,7 +42,7 @@ def __iter__(self):
4242
url,params,cls=self.url,self.params,self.cls
4343
headers=self.headers
4444

45-
ifparamsand'per_page'notinparams:
45+
if'per_page'notinparams:
4646
params['per_page']=100
4747

4848
while (self.count==-1orself.count>0)andurl:

‎tests/unit/test_structs.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from .helperimportUnitHelper
2+
fromgithub3.structsimportGitHubIterator
3+
4+
importmock
5+
6+
7+
classTestGitHubIterator(UnitHelper):
8+
described_class=GitHubIterator
9+
10+
defcreate_instance_of_described_class(self):
11+
self.url='https://api.github.com/users'
12+
klass=lambda*args:args
13+
instance=self.described_class(count=-1,url=self.url,cls=klass,
14+
session=self.session)
15+
returninstance
16+
17+
deftest_sets_per_page_to_100(self):
18+
"""Test that the Iterator defaults the per_page parameter to 100"""
19+
self.session.get.return_value=mock.Mock(status_code=200,
20+
json=lambda: [],
21+
links={})
22+
23+
foriinself.instance:
24+
break
25+
26+
self.session.get.assert_called_once_with(
27+
self.url,params={'per_page':100},headers={}
28+
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp