From 78374b9d5e2f585034976389eedd367c3595f07f Mon Sep 17 00:00:00 2001 From: Jannis Gebauer Date: Thu, 8 Sep 2016 10:46:06 +0200 Subject: [PATCH] sort params and make them work on py3 --- github/GithubObject.py | 2 +- github/tests/CommitCombinedStatus.py | 2 +- github/tests/CommitComment.py | 2 +- github/tests/CommitStatus.py | 2 +- github/tests/Event.py | 2 +- github/tests/GistComment.py | 2 +- github/tests/GitTag.py | 2 +- github/tests/Hook.py | 2 +- github/tests/Issue.py | 2 +- github/tests/IssueComment.py | 2 +- github/tests/PullRequest.py | 2 +- github/tests/PullRequestComment.py | 2 +- github/tests/Tag.py | 2 +- github/tests/Team.py | 2 +- github/tests/UserKey.py | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/github/GithubObject.py b/github/GithubObject.py index c6841fdd..82241ef3 100644 --- a/github/GithubObject.py +++ b/github/GithubObject.py @@ -219,7 +219,7 @@ class GithubObject(object): items = params.items() else: items = list(params.items()) - for k, v in sorted(items, key=itemgetter(1)): + for k, v in sorted(items, key=itemgetter(0), reverse=True): yield '{k}="{v}"'.format(k=k, v=v) if isinstance(v, (str, unicode)) else '{k}={v}'.format(k=k, v=v) return '{class_name}({params})'.format( class_name=self.__class__.__name__, diff --git a/github/tests/CommitCombinedStatus.py b/github/tests/CommitCombinedStatus.py index eb6c30b1..18c8fc10 100644 --- a/github/tests/CommitCombinedStatus.py +++ b/github/tests/CommitCombinedStatus.py @@ -52,4 +52,4 @@ class CommitCombinedStatus(Framework.TestCase): # test __repr__() based on this attributes self.assertEqual(self.combined_status.__repr__(), - 'CommitCombinedStatus(sha="74e70119a23fa3ffb3db19d4590eccfebd72b659", state="success")') \ No newline at end of file + 'CommitCombinedStatus(state="success", sha="74e70119a23fa3ffb3db19d4590eccfebd72b659")') \ No newline at end of file diff --git a/github/tests/CommitComment.py b/github/tests/CommitComment.py index 0bf45d1b..90bb0024 100644 --- a/github/tests/CommitComment.py +++ b/github/tests/CommitComment.py @@ -49,7 +49,7 @@ class CommitComment(Framework.TestCase): # test __repr__() based on this attributes self.assertEqual(self.comment.__repr__(), - 'CommitComment(id=1361949, user=NamedUser(login="jacquev6"))') + 'CommitComment(user=NamedUser(login="jacquev6"), id=1361949)') def testEdit(self): self.comment.edit("Comment edited by PyGithub") diff --git a/github/tests/CommitStatus.py b/github/tests/CommitStatus.py index 99828e2a..73dec203 100644 --- a/github/tests/CommitStatus.py +++ b/github/tests/CommitStatus.py @@ -50,4 +50,4 @@ class CommitStatus(Framework.TestCase): # test __repr__() based on this attributes self.assertEqual(self.statuses[0].__repr__(), - 'CommitStatus(id=277040, context="build", state="success")') \ No newline at end of file + 'CommitStatus(state="success", id=277040, context="build")') \ No newline at end of file diff --git a/github/tests/Event.py b/github/tests/Event.py index 3d5d4b80..87e65acd 100644 --- a/github/tests/Event.py +++ b/github/tests/Event.py @@ -45,4 +45,4 @@ class Event(Framework.TestCase): self.assertEqual(self.event.type, "PushEvent") # test __repr__() based on this attributes - self.assertEqual(self.event.__repr__(), 'Event(id="1556114751", type="PushEvent")') + self.assertEqual(self.event.__repr__(), 'Event(type="PushEvent", id="1556114751")') diff --git a/github/tests/GistComment.py b/github/tests/GistComment.py index 9e990a5d..80146c42 100644 --- a/github/tests/GistComment.py +++ b/github/tests/GistComment.py @@ -43,7 +43,7 @@ class GistComment(Framework.TestCase): self.assertEqual(self.comment.user.login, "jacquev6") # test __repr__() based on this attributes - self.assertEqual(self.comment.__repr__(), 'GistComment(id=323629, user=NamedUser(login="jacquev6"))') + self.assertEqual(self.comment.__repr__(), 'GistComment(user=NamedUser(login="jacquev6"), id=323629)') def testEdit(self): self.comment.edit("Comment edited by PyGithub") diff --git a/github/tests/GitTag.py b/github/tests/GitTag.py index 374f2207..44adf317 100644 --- a/github/tests/GitTag.py +++ b/github/tests/GitTag.py @@ -47,4 +47,4 @@ class GitTag(Framework.TestCase): self.assertEqual(self.tag.url, "https://api.github.com/repos/jacquev6/PyGithub/git/tags/f5f37322407b02a80de4526ad88d5f188977bc3c") # test __repr__() based on this attributes - self.assertEqual(self.tag.__repr__(), 'GitTag(sha="f5f37322407b02a80de4526ad88d5f188977bc3c", tag="v0.6")') \ No newline at end of file + self.assertEqual(self.tag.__repr__(), 'GitTag(tag="v0.6", sha="f5f37322407b02a80de4526ad88d5f188977bc3c")') \ No newline at end of file diff --git a/github/tests/Hook.py b/github/tests/Hook.py index f55d1297..df5f682e 100644 --- a/github/tests/Hook.py +++ b/github/tests/Hook.py @@ -48,7 +48,7 @@ class Hook(Framework.TestCase): self.assertEqual(self.hook.url, "https://api.github.com/repos/jacquev6/PyGithub/hooks/257993") # test __repr__() based on this attributes - self.assertEqual(self.hook.__repr__(), 'Hook(id=257993, url="https://api.github.com/repos/jacquev6/PyGithub/hooks/257993")') + self.assertEqual(self.hook.__repr__(), 'Hook(url="https://api.github.com/repos/jacquev6/PyGithub/hooks/257993", id=257993)') def testEditWithMinimalParameters(self): self.hook.edit("web", {"url": "http://foobar.com/hook"}) diff --git a/github/tests/Issue.py b/github/tests/Issue.py index 846e13d5..39b3268e 100644 --- a/github/tests/Issue.py +++ b/github/tests/Issue.py @@ -59,7 +59,7 @@ class Issue(Framework.TestCase): self.assertEqual(self.issue.repository.name, "PyGithub") # test __repr__() based on this attributes - self.assertEqual(self.issue.__repr__(), 'Issue(number=28, title="Issue created by PyGithub")') + self.assertEqual(self.issue.__repr__(), 'Issue(title="Issue created by PyGithub", number=28)') def testEditWithoutParameters(self): self.issue.edit() diff --git a/github/tests/IssueComment.py b/github/tests/IssueComment.py index 41821c2e..1e2dae78 100644 --- a/github/tests/IssueComment.py +++ b/github/tests/IssueComment.py @@ -44,7 +44,7 @@ class IssueComment(Framework.TestCase): self.assertEqual(self.comment.html_url, "https://github.com/jacquev6/PyGithub/issues/28#issuecomment-5808311") # test __repr__() based on this attributes - self.assertEqual(self.comment.__repr__(), 'IssueComment(id=5808311, user=NamedUser(login="jacquev6"))') + self.assertEqual(self.comment.__repr__(), 'IssueComment(user=NamedUser(login="jacquev6"), id=5808311)') def testEdit(self): self.comment.edit("Comment edited by PyGithub") diff --git a/github/tests/PullRequest.py b/github/tests/PullRequest.py index a622d14f..d4923978 100644 --- a/github/tests/PullRequest.py +++ b/github/tests/PullRequest.py @@ -69,7 +69,7 @@ class PullRequest(Framework.TestCase): self.assertEqual(self.pull.user.login, "jacquev6") # test __repr__() based on this attributes - self.assertEqual(self.pull.__repr__(), 'PullRequest(number=31, title="Title edited by PyGithub")') + self.assertEqual(self.pull.__repr__(), 'PullRequest(title="Title edited by PyGithub", number=31)') def testCreateComment(self): commit = self.repo.get_commit("8a4f306d4b223682dd19410d4a9150636ebe4206") diff --git a/github/tests/PullRequestComment.py b/github/tests/PullRequestComment.py index 716e8442..bcdef2b4 100644 --- a/github/tests/PullRequestComment.py +++ b/github/tests/PullRequestComment.py @@ -49,7 +49,7 @@ class PullRequestComment(Framework.TestCase): self.assertEqual(self.comment.html_url, "https://github.com/jacquev6/PyGithub/pull/170#issuecomment-18637907") # test __repr__() based on this attributes - self.assertEqual(self.comment.__repr__(), 'PullRequestComment(id=886298, user=NamedUser(login="jacquev6"))') + self.assertEqual(self.comment.__repr__(), 'PullRequestComment(user=NamedUser(login="jacquev6"), id=886298)') def testEdit(self): diff --git a/github/tests/Tag.py b/github/tests/Tag.py index 8150e881..5ddefe0f 100644 --- a/github/tests/Tag.py +++ b/github/tests/Tag.py @@ -39,4 +39,4 @@ class Tag(Framework.TestCase): self.assertEqual(self.tag.zipball_url, "https://github.com/jacquev6/PyGithub/zipball/v0.3") # test __repr__() based on this attributes - self.assertEqual(self.tag.__repr__(), 'Tag(commit=Commit(sha="636e6112deb72277b3bffcc3303cd7e8a7431a5d"), name="v0.3")') + self.assertEqual(self.tag.__repr__(), 'Tag(name="v0.3", commit=Commit(sha="636e6112deb72277b3bffcc3303cd7e8a7431a5d"))') diff --git a/github/tests/Team.py b/github/tests/Team.py index f7bcd268..b12208d6 100644 --- a/github/tests/Team.py +++ b/github/tests/Team.py @@ -42,7 +42,7 @@ class Team(Framework.TestCase): self.assertEqual(self.team.url, "https://api.github.com/teams/189850") # test __repr__() based on this attributes - self.assertEqual(self.team.__repr__(), 'Team(id=189850, name="Team created by PyGithub")') + self.assertEqual(self.team.__repr__(), 'Team(name="Team created by PyGithub", id=189850)') def testMembers(self): user = self.g.get_user("jacquev6") diff --git a/github/tests/UserKey.py b/github/tests/UserKey.py index 8e084220..a3e305c9 100644 --- a/github/tests/UserKey.py +++ b/github/tests/UserKey.py @@ -40,7 +40,7 @@ class UserKey(Framework.TestCase): self.assertTrue(self.key.verified) # test __repr__() based on this attributes - self.assertEqual(self.key.__repr__(), 'UserKey(id=2626650, title="Key added through PyGithub")') + self.assertEqual(self.key.__repr__(), 'UserKey(title="Key added through PyGithub", id=2626650)') def testEditWithoutArguments(self): self.key.edit()