Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixes for latest version of pep8
  • Loading branch information
lovelydinosaur committed Feb 9, 2015
commit b2939c157d32e604e10099be891e382d8c54bbec
1 change: 1 addition & 0 deletions env/pip-selfcheck.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"last_check":"2015-02-09T17:34:33Z","pypi_version":"6.0.8"}
4 changes: 3 additions & 1 deletion rest_framework/templatetags/rest_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ def urlize_quoted_links(text, trim_url_limit=None, nofollow=True, autoescape=Tru

If autoescape is True, the link text and URLs will get autoescaped.
"""
trim_url = lambda x, limit=trim_url_limit: limit is not None and (len(x) > limit and ('%s...' % x[:max(0, limit - 3)])) or x
def trim_url(x, limit=trim_url_limit):
return limit is not None and (len(x) > limit and ('%s...' % x[:max(0, limit - 3)])) or x
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I'd feel better if these conditional and y or x lines were replaced with explicit Python conditional assignment statements.

return ('%s...' % x[:max(0, limit - 3)]) if limit and len(x) > limit else x

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. We're just cloning from the Django codebase here so I don't particularly mind that it's a bit rubbish in this case.


safe_input = isinstance(text, SafeData)
words = word_split_re.split(force_text(text))
for i, word in enumerate(words):
Expand Down
5 changes: 4 additions & 1 deletion tests/test_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ def test_post_json_passing_token_auth(self):
def test_post_json_makes_one_db_query(self):
"""Ensure that authenticating a user using a token performs only one DB query"""
auth = "Token " + self.key
func_to_test = lambda: self.csrf_client.post('/token/', {'example': 'example'}, format='json', HTTP_AUTHORIZATION=auth)

def func_to_test():
return self.csrf_client.post('/token/', {'example': 'example'}, format='json', HTTP_AUTHORIZATION=auth)

self.assertNumQueries(1, func_to_test)

def test_post_form_failing_token_auth(self):
Expand Down
4 changes: 3 additions & 1 deletion tests/test_relations_hyperlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
request = factory.get('/') # Just to ensure we have a request in the serializer context


dummy_view = lambda request, pk: None
def dummy_view(request, pk):
pass


urlpatterns = patterns(
'',
Expand Down
9 changes: 7 additions & 2 deletions tests/test_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@
DUMMYSTATUS = status.HTTP_200_OK
DUMMYCONTENT = 'dummycontent'

RENDERER_A_SERIALIZER = lambda x: ('Renderer A: %s' % x).encode('ascii')
RENDERER_B_SERIALIZER = lambda x: ('Renderer B: %s' % x).encode('ascii')

def RENDERER_A_SERIALIZER(x):
return ('Renderer A: %s' % x).encode('ascii')


def RENDERER_B_SERIALIZER(x):
return ('Renderer B: %s' % x).encode('ascii')


expected_results = [
Expand Down
9 changes: 7 additions & 2 deletions tests/test_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ class MockTextMediaRenderer(BaseRenderer):
DUMMYSTATUS = status.HTTP_200_OK
DUMMYCONTENT = 'dummycontent'

RENDERER_A_SERIALIZER = lambda x: ('Renderer A: %s' % x).encode('ascii')
RENDERER_B_SERIALIZER = lambda x: ('Renderer B: %s' % x).encode('ascii')

def RENDERER_A_SERIALIZER(x):
return ('Renderer A: %s' % x).encode('ascii')


def RENDERER_B_SERIALIZER(x):
return ('Renderer B: %s' % x).encode('ascii')


class RendererA(BaseRenderer):
Expand Down
8 changes: 6 additions & 2 deletions tests/test_throttling.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ def setUp(self):
class XYScopedRateThrottle(ScopedRateThrottle):
TIMER_SECONDS = 0
THROTTLE_RATES = {'x': '3/min', 'y': '1/min'}
timer = lambda self: self.TIMER_SECONDS

def timer(self):
return self.TIMER_SECONDS

class XView(APIView):
throttle_classes = (XYScopedRateThrottle,)
Expand Down Expand Up @@ -290,7 +292,9 @@ def setUp(self):
class Throttle(ScopedRateThrottle):
THROTTLE_RATES = {'test_limit': '1/day'}
TIMER_SECONDS = 0
timer = lambda self: self.TIMER_SECONDS

def timer(self):
return self.TIMER_SECONDS

class View(APIView):
throttle_classes = (Throttle,)
Expand Down