Skip to content

Commit

Permalink
Correctly compare length of argument vector to argument position
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-hilden committed Feb 17, 2020
1 parent 01aaece commit 33f9013
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tekore/client/decor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def decorator(function: Callable) -> Callable:

@wraps(function)
def wrapper(self, *args, **kwargs):
if self.max_limits_on and len(args) < arg_pos:
if self.max_limits_on and len(args) <= arg_pos:
kwargs.setdefault('limit', max_limit)
return function(self, *args, **kwargs)
return wrapper
Expand Down
8 changes: 8 additions & 0 deletions tests/client/full.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ def test_specifying_limit_pos_arg_overrides_max_limits(self):

self.assertEqual(s.limit, 1)

def test_specifying_pos_args_until_limit(self):
client = Spotify(self.user_token, max_limits_on=True)
s1, = client.search('piano', ('track',), None, None)
with client.max_limits(False):
s2, = client.search('piano', ('track',), None, None)

self.assertGreater(s1.limit, s2.limit)


class TestSpotifyPaging(TestCaseWithUserCredentials):
@classmethod
Expand Down

0 comments on commit 33f9013

Please sign in to comment.