8000 Use helper function · qiwsir/github3.py@67a19a8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 67a19a8

Browse files
committed
Use helper function
1 parent 3a993e3 commit 67a19a8

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

HISTORY.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,22 @@ Old name New attribute name
236236
- ``Repository.stargazers`` is now ``Repository.stargazers_count`` (conforming
237237
with the attribute name returned by the API).
238238

239+
240+
- The ``Issue`` API has changed in order to provide a more consistent attribute
241+
API. ``Issue.comments`` is now ``Issue.comments_count`` and returns the
242+
number of comments on an issue.
243+
244+
- The ``Issue.labels`` attribute has also been renamed. It is now available from
245+
``Issue.original_labels``. This will provide the user with the list of
246+
``Label`` objects that was returned by the API. To retrieve an updated list
247+
of labels, the user can now use ``Issue#labels``, e.g.
248+
249+
::
250+
251+
i = github3.issue('sigmavirus24', 'github3.py', 30)
252+
labels = list(i.labels())
253+
254+
239255
0.9.0: 2014-05-04
240256
~~~~~~~~~~~~~~~~~
241257

github3/issues/issue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(self, issue, session=None):
5151
self.closed_at = self._strptime(issue.get('closed_at'))
5252

5353
#: Number of comments on this issue.
54-
self.comments = issue.get('comments')
54+
self.comments_count = issue.get('comments')
5555
#: Comments url (not a template)
5656
self.comments_url = issue.get('comments_url')
5757
#: datetime object representing when the issue was created.

tests/unit/test_pulls.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
"""Unit tests for the github3.pulls module."""
2-
import json
3-
import os
42
import pytest
53

6-
from .helper import UnitHelper, UnitIteratorHelper, create_url_helper
4+
from .helper import (UnitHelper, UnitIteratorHelper, create_url_helper,
5+
create_example_data_helper)
76

87
from github3 import GitHubError
98
from github3.pulls import PullRequest
109

11-
12-
def get_pr_example_data():
13-
"""Load the example data for the PullRequest object."""
14-
directory = os.path.dirname(__file__)
15-
example = os.path.join(directory, 'pull_request_example')
16-
with open(example) as fd:
17-
data = json.load(fd)
18-
return data
10+
get_pr_example_data = create_example_data_helper('pull_request_example')
1911

2012

2113
url_for = create_url_helper(

0 commit comments

Comments
 (0)
0