mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-29 17:39:48 +03:00
coverage increase and ignore runtest and setup files from coverage
This commit is contained in:
parent
7855d3bd8b
commit
3261c67ea2
32
runtests.py
32
runtests.py
|
@ -1,37 +1,37 @@
|
||||||
#! /usr/bin/env python
|
#! /usr/bin/env python
|
||||||
from __future__ import print_function
|
from __future__ import print_function # pragma nocover
|
||||||
|
|
||||||
import os
|
import os # pragma nocover
|
||||||
import subprocess
|
import subprocess # pragma nocover
|
||||||
import sys
|
import sys # pragma nocover
|
||||||
|
|
||||||
import pytest
|
import pytest # pragma nocover
|
||||||
|
|
||||||
PYTEST_ARGS = {
|
PYTEST_ARGS = { # pragma nocover
|
||||||
'default': ['tests', '--tb=short', '-s', '-rw'],
|
'default': ['tests', '--tb=short', '-s', '-rw'],
|
||||||
'fast': ['tests', '--tb=short', '-q', '-s', '-rw'],
|
'fast': ['tests', '--tb=short', '-q', '-s', '-rw'],
|
||||||
}
|
}
|
||||||
|
|
||||||
FLAKE8_ARGS = ['rest_framework', 'tests']
|
FLAKE8_ARGS = ['rest_framework', 'tests'] # pragma nocover
|
||||||
|
|
||||||
ISORT_ARGS = ['--recursive', '--check-only', '-o' 'uritemplate', '-p', 'tests', 'rest_framework', 'tests']
|
ISORT_ARGS = ['--recursive', '--check-only', '-o' 'uritemplate', '-p', 'tests', 'rest_framework', 'tests'] # pragma nocover
|
||||||
|
|
||||||
sys.path.append(os.path.dirname(__file__))
|
sys.path.append(os.path.dirname(__file__)) # pragma nocover
|
||||||
|
|
||||||
|
|
||||||
def exit_on_failure(ret, message=None):
|
def exit_on_failure(ret, message=None): # pragma nocover
|
||||||
if ret:
|
if ret:
|
||||||
sys.exit(ret)
|
sys.exit(ret)
|
||||||
|
|
||||||
|
|
||||||
def flake8_main(args):
|
def flake8_main(args): # pragma nocover
|
||||||
print('Running flake8 code linting')
|
print('Running flake8 code linting')
|
||||||
ret = subprocess.call(['flake8'] + args)
|
ret = subprocess.call(['flake8'] + args)
|
||||||
print('flake8 failed' if ret else 'flake8 passed')
|
print('flake8 failed' if ret else 'flake8 passed')
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def isort_main(args):
|
def isort_main(args): # pragma nocover
|
||||||
print('Running isort code checking')
|
print('Running isort code checking')
|
||||||
ret = subprocess.call(['isort'] + args)
|
ret = subprocess.call(['isort'] + args)
|
||||||
|
|
||||||
|
@ -43,22 +43,22 @@ def isort_main(args):
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def split_class_and_function(string):
|
def split_class_and_function(string): # pragma nocover
|
||||||
class_string, function_string = string.split('.', 1)
|
class_string, function_string = string.split('.', 1)
|
||||||
return "%s and %s" % (class_string, function_string)
|
return "%s and %s" % (class_string, function_string)
|
||||||
|
|
||||||
|
|
||||||
def is_function(string):
|
def is_function(string): # pragma nocover
|
||||||
# `True` if it looks like a test function is included in the string.
|
# `True` if it looks like a test function is included in the string.
|
||||||
return string.startswith('test_') or '.test_' in string
|
return string.startswith('test_') or '.test_' in string
|
||||||
|
|
||||||
|
|
||||||
def is_class(string):
|
def is_class(string): # pragma nocover
|
||||||
# `True` if first character is uppercase - assume it's a class name.
|
# `True` if first character is uppercase - assume it's a class name.
|
||||||
return string[0] == string[0].upper()
|
return string[0] == string[0].upper()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__": # pragma nocover
|
||||||
try:
|
try:
|
||||||
sys.argv.remove('--nolint')
|
sys.argv.remove('--nolint')
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
26
setup.py
26
setup.py
|
@ -1,26 +1,26 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import os
|
import os # pragma nocover
|
||||||
import re
|
import re # pragma nocover
|
||||||
import shutil
|
import shutil # pragma nocover
|
||||||
import sys
|
import sys # pragma nocover
|
||||||
from io import open
|
from io import open # pragma nocover
|
||||||
|
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages # pragma nocover
|
||||||
|
|
||||||
try:
|
try: # pragma nocover
|
||||||
from pypandoc import convert_file
|
from pypandoc import convert_file
|
||||||
|
|
||||||
def read_md(f):
|
def read_md(f):
|
||||||
return convert_file(f, 'rst')
|
return convert_file(f, 'rst')
|
||||||
except ImportError:
|
except ImportError: # pragma nocover
|
||||||
print("warning: pypandoc module not found, could not convert Markdown to RST")
|
print("warning: pypandoc module not found, could not convert Markdown to RST")
|
||||||
|
|
||||||
def read_md(f):
|
def read_md(f): # pragma nocover
|
||||||
return open(f, 'r', encoding='utf-8').read()
|
return open(f, 'r', encoding='utf-8').read()
|
||||||
|
|
||||||
|
|
||||||
def get_version(package):
|
def get_version(package): # pragma nocover
|
||||||
"""
|
"""
|
||||||
Return package version as listed in `__version__` in `init.py`.
|
Return package version as listed in `__version__` in `init.py`.
|
||||||
"""
|
"""
|
||||||
|
@ -28,10 +28,10 @@ def get_version(package):
|
||||||
return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)
|
return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)
|
||||||
|
|
||||||
|
|
||||||
version = get_version('rest_framework')
|
version = get_version('rest_framework') # pragma nocover
|
||||||
|
|
||||||
|
|
||||||
if sys.argv[-1] == 'publish':
|
if sys.argv[-1] == 'publish': # pragma nocover
|
||||||
try:
|
try:
|
||||||
import pypandoc
|
import pypandoc
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -50,7 +50,7 @@ if sys.argv[-1] == 'publish':
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup( # pragma nocover
|
||||||
name='djangorestframework',
|
name='djangorestframework',
|
||||||
version=version,
|
version=version,
|
||||||
url='http://www.django-rest-framework.org',
|
url='http://www.django-rest-framework.org',
|
||||||
|
|
|
@ -5,7 +5,7 @@ from django.utils import six
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from rest_framework.exceptions import (
|
from rest_framework.exceptions import (
|
||||||
ErrorDetail, Throttled, _get_error_details
|
ErrorDetail, Throttled, _get_error_details, ValidationError
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,6 +37,11 @@ class ExceptionTestCase(TestCase):
|
||||||
ErrorDetail
|
ErrorDetail
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_validation_error_no_detail(self):
|
||||||
|
exception = ValidationError(detail=None)
|
||||||
|
assert exception.get_full_details() == [{
|
||||||
|
'message': 'Invalid input.', 'code': 'invalid'}]
|
||||||
|
|
||||||
def test_get_full_details_with_throttling(self):
|
def test_get_full_details_with_throttling(self):
|
||||||
exception = Throttled()
|
exception = Throttled()
|
||||||
assert exception.get_full_details() == {
|
assert exception.get_full_details() == {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user