From 8995ff5efe0d892a806f00bfa42887269e2238b1 Mon Sep 17 00:00:00 2001 From: mattsb42 Date: Sun, 2 Feb 2020 14:40:05 -0800 Subject: [PATCH 1/2] re-add test_dependencies and extras to fix tox --- setup.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/setup.py b/setup.py index c9b753f..fd3fbc5 100755 --- a/setup.py +++ b/setup.py @@ -7,11 +7,19 @@ version = '2.2.2' +test_requirements = ['pytest'] + +extras = { + "test": test_requirements, +} + setup(name='agithub', version=version, description="A lightweight, transparent syntax for REST clients", long_description=long_description, long_description_content_type='text/markdown', + tests_require=test_requirements, + extras_require=extras, classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Console', From c1f18aeaf9683505c38f6c3c60989608a5e45ce8 Mon Sep 17 00:00:00 2001 From: mattsb42 Date: Sun, 2 Feb 2020 14:40:43 -0800 Subject: [PATCH 2/2] make IncompleteRequest.__getattr__ return a new instance rather than mutating self --- agithub/agithub_test.py | 8 ++++---- agithub/base.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/agithub/agithub_test.py b/agithub/agithub_test.py index ad79144..80d5ca9 100755 --- a/agithub/agithub_test.py +++ b/agithub/agithub_test.py @@ -57,8 +57,8 @@ def newIncompleteRequest(self): def test_pathByGetAttr(self): rb = self.newIncompleteRequest() - rb.hug.an.octocat - self.assertEqual(rb.url, "/hug/an/octocat") + test = rb.hug.an.octocat + self.assertEqual(test.url, "/hug/an/octocat") def test_callMethodDemo(self): rb = self.newIncompleteRequest() @@ -73,8 +73,8 @@ def test_callMethodDemo(self): def test_pathByGetItem(self): rb = self.newIncompleteRequest() - rb["hug"][1]["octocat"] - self.assertEqual(rb.url, "/hug/1/octocat") + test = rb["hug"][1]["octocat"] + self.assertEqual(test.url, "/hug/1/octocat") def test_callMethodTest(self): rb = self.newIncompleteRequest() diff --git a/agithub/base.py b/agithub/base.py index 88b8a31..2c54a88 100644 --- a/agithub/base.py +++ b/agithub/base.py @@ -79,9 +79,9 @@ class IncompleteRequest(object): To understand the method(...) calls, check out github.client.Client. """ - def __init__(self, client): + def __init__(self, client, url=""): self.client = client - self.url = '' + self.url = url def __getattr__(self, key): if key in self.client.http_methods: @@ -89,8 +89,8 @@ def __getattr__(self, key): wrapper = partial(htmlMethod, url=self.url) return update_wrapper(wrapper, htmlMethod) else: - self.url += '/' + str(key) - return self + new_url = self.url + '/' + str(key) + return IncompleteRequest(self.client, new_url) __getitem__ = __getattr__