Skip to content

Commit 390061b

Browse files
committed
Merge pull request #1780 from tomchristie/pytest-tweaks
Added `runtests.py` and `flake8` code linting.
2 parents e385a7b + 2d2737f commit 390061b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+594
-354
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ install:
1919
- pip install Pillow==2.3.0
2020
- pip install django-guardian==1.2.3
2121
- pip install pytest-django==2.6.1
22+
- pip install flake8==2.2.2
2223
- "if [[ ${TRAVIS_PYTHON_VERSION::1} != '3' ]]; then pip install oauth2==1.5.211; fi"
2324
- "if [[ ${TRAVIS_PYTHON_VERSION::1} != '3' ]]; then pip install django-oauth-plus==2.2.4; fi"
2425
- "if [[ ${TRAVIS_PYTHON_VERSION::1} != '3' ]]; then pip install django-oauth2-provider==0.2.4; fi"
@@ -28,7 +29,7 @@ install:
2829
- export PYTHONPATH=.
2930

3031
script:
31-
- py.test
32+
- ./runtests.py
3233

3334
matrix:
3435
exclude:

pytest.ini

Lines changed: 0 additions & 2 deletions
This file was deleted.

optionals.txt renamed to requirements-test.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Test requirements
2+
pytest-django==2.6
3+
pytest==2.5.2
4+
pytest-cov==1.6
5+
flake8==2.2.2
6+
7+
# Optional packages
18
markdown>=2.1.0
29
PyYAML>=3.10
310
defusedxml>=0.3

requirements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
-e .
21
Django>=1.3
3-
pytest-django==2.6

rest_framework/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""
2-
______ _____ _____ _____ __ _
3-
| ___ \ ___/ ___|_ _| / _| | |
4-
| |_/ / |__ \ `--. | | | |_ _ __ __ _ _ __ ___ _____ _____ _ __| | __
2+
______ _____ _____ _____ __
3+
| ___ \ ___/ ___|_ _| / _| | |
4+
| |_/ / |__ \ `--. | | | |_ _ __ __ _ _ __ ___ _____ _____ _ __| |__
55
| /| __| `--. \ | | | _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
6-
| |\ \| |___/\__/ / | | | | | | | (_| | | | | | | __/\ V V / (_) | | | <
6+
| |\ \| |___/\__/ / | | | | | | | (_| | | | | | | __/\ V V / (_) | | | <
77
\_| \_\____/\____/ \_/ |_| |_| \__,_|_| |_| |_|\___| \_/\_/ \___/|_| |_|\_|
88
"""
99

rest_framework/authentication.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def get_authorization_header(request):
2121
Hide some test client ickyness where the header can be unicode.
2222
"""
2323
auth = request.META.get('HTTP_AUTHORIZATION', b'')
24-
if type(auth) == type(''):
24+
if isinstance(auth, type('')):
2525
# Work around django test client oddness
2626
auth = auth.encode(HTTP_HEADER_ENCODING)
2727
return auth

rest_framework/authtoken/models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import binascii
22
import os
3-
from hashlib import sha1
43
from django.conf import settings
54
from django.db import models
65

rest_framework/authtoken/south_migrations/0001_initial.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
# -*- coding: utf-8 -*-
2-
import datetime
32
from south.db import db
43
from south.v2 import SchemaMigration
5-
from django.db import models
6-
7-
from rest_framework.settings import api_settings
8-
94

105
try:
116
from django.contrib.auth import get_user_model
12-
except ImportError: # django < 1.5
7+
except ImportError: # django < 1.5
138
from django.contrib.auth.models import User
149
else:
1510
User = get_user_model()
@@ -26,12 +21,10 @@ def forwards(self, orm):
2621
))
2722
db.send_create_signal('authtoken', ['Token'])
2823

29-
3024
def backwards(self, orm):
3125
# Deleting model 'Token'
3226
db.delete_table('authtoken_token')
3327

34-
3528
models = {
3629
'auth.group': {
3730
'Meta': {'object_name': 'Group'},

rest_framework/decorators.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ def decorator(func):
131131
return func
132132
return decorator
133133

134+
134135
# These are now pending deprecation, in favor of `detail_route` and `list_route`.
135136

136137
def link(**kwargs):
@@ -139,11 +140,13 @@ def link(**kwargs):
139140
"""
140141
msg = 'link is pending deprecation. Use detail_route instead.'
141142
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
143+
142144
def decorator(func):
143145
func.bind_to_methods = ['get']
144146
func.detail = True
145147
func.kwargs = kwargs
146148
return func
149+
147150
return decorator
148151

149152

@@ -153,9 +156,11 @@ def action(methods=['post'], **kwargs):
153156
"""
154157
msg = 'action is pending deprecation. Use detail_route instead.'
155158
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
159+
156160
def decorator(func):
157161
func.bind_to_methods = methods
158162
func.detail = True
159163
func.kwargs = kwargs
160164
return func
161-
return decorator
165+
166+
return decorator

rest_framework/exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def __init__(self, detail=None):
2323
def __str__(self):
2424
return self.detail
2525

26+
2627
class ParseError(APIException):
2728
status_code = status.HTTP_400_BAD_REQUEST
2829
default_detail = 'Malformed request.'

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy