8000 Merge pull request #778 from matthew-23/develop · pythonthings/github3.py@17d0fb9 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 17d0fb9

Browse files
authored
Merge pull request sigmavirus24#778 from matthew-23/develop
fix bug#777: close issue failed with unicode labels
2 parents f8487f7 + 8cd184d commit 17d0fb9

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

github3/issues/issue.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ def close(self):
147147
"""
148148
assignee = self.assignee.login if self.assignee else ''
149149
number = self.milestone.number if self.milestone else None
150-
labels = [str(l) for l in self.original_labels]
150+
labels = [l.name for l in self.original_labels]
151+
151152
return self.edit(self.title, self.body, assignee, 'closed',
152153
number, labels)
153154

tests/unit/test_issues_issue.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
"""Unit tests for the Issue class."""
23
import github3
34
import mock
@@ -31,7 +32,6 @@
3132

3233

3334
class TestIssueRequiresAuth(helper.UnitRequiresAuthenticationHelper):
34-
3535
"""Test Issue methods that require Authentication."""
3636

3737
described_class = github3.issues.Issue
@@ -83,7 +83,6 @@ def test_unlock(self):
8383

8484

8585
class TestIssue(helper.UnitHelper):
86-
8786
"""Test Issue methods that make simple requests."""
8887

8988
described_class = github3.issues.Issue
@@ -120,7 +119,8 @@ def test_assign_empty_username(self):
120119
def test_close(self):
121120
"""Verify the request for closing an issue."""
122121
self.instance.close()
123-
labels = [str(label) for label in self.instance.original_labels]
122+
labels = [label.name for label in self.instance.original_labels]
123+
124124
self.patch_called_with(
125125
url_for(),
126126
data={
@@ -169,6 +169,21 @@ def test_comment_positive_id(self):
169169
self.instance.comment(-1)
170170
assert self.session.get.called is False
171171

172+
def test_close_with_unicode_labels(self):
173+
"""Verify the request for closing an issue."""
174+
data = {
175+
'title': 10000 'issue title',
176+
'body': 'issue body',
177+
'assignee': 'sigmavirus24',
178+
'state': 'closed',
179+
'labels': [u"标签1", u"标签2"]
180+
}
181+
self.instance.edit(**data)
182+
self.patch_called_with(
183+
url_for(),
184+
data=data
185+
)
186+
172187
def test_edit(self):
173188
"""Verify the request for editing an issue."""
174189
data = {
@@ -324,7 +339,6 @@ def test_replace_labels(self):
324339

325340

326341
class TestIssueIterators(helper.UnitIteratorHelper):
327-
328342
"""Test Issue methods that return iterators."""
329343

330344
described_class = github3.issues.Issue
@@ -365,7 +379,6 @@ def test_labels(self):
365379

366380

367381
class TestLabelRequiresAuth(helper.UnitRequiresAuthenticationHelper):
368-
369382
"""Test that ensure certain methods on Label class requires auth."""
370383

371384
described_class = github3.issues.label.Label
@@ -430,7 +443,6 @@ def test_update(self):
430443

431444

432445
class TestIssueEvent(helper.UnitHelper):
433-
434446
"""Unit test for IssueEvent."""
435447

436448
described_class = github3.issues.event.IssueEvent

0 commit comments

Comments
 (0)
0