prefer single quotes in source and double quotes in user visible strings; add some missing full stops to user visible strings

This commit is contained in:
Craig Blaszczyk 2015-01-07 12:46:23 +00:00
parent 9a4267049b
commit 91e316f781
13 changed files with 107 additions and 106 deletions

View File

@ -66,16 +66,16 @@ class BasicAuthentication(BaseAuthentication):
return None
if len(auth) == 1:
msg = _("Invalid basic header. No credentials provided.")
msg = _('Invalid basic header. No credentials provided.')
raise exceptions.AuthenticationFailed(msg)
elif len(auth) > 2:
msg = _("Invalid basic header. Credentials string should not contain spaces.")
msg = _('Invalid basic header. Credentials string should not contain spaces.')
raise exceptions.AuthenticationFailed(msg)
try:
auth_parts = base64.b64decode(auth[1]).decode(HTTP_HEADER_ENCODING).partition(':')
except (TypeError, UnicodeDecodeError):
msg = _("Invalid basic header. Credentials not correctly base64 encoded.")
msg = _('Invalid basic header. Credentials not correctly base64 encoded.')
raise exceptions.AuthenticationFailed(msg)
userid, password = auth_parts[0], auth_parts[2]
@ -87,7 +87,7 @@ class BasicAuthentication(BaseAuthentication):
"""
user = authenticate(username=userid, password=password)
if user is None or not user.is_active:
raise exceptions.AuthenticationFailed(_("Invalid username/password."))
raise exceptions.AuthenticationFailed(_('Invalid username/password.'))
return (user, None)
def authenticate_header(self, request):
@ -153,10 +153,10 @@ class TokenAuthentication(BaseAuthentication):
return None
if len(auth) == 1:
msg = _("Invalid token header. No credentials provided.")
msg = _('Invalid token header. No credentials provided.')
raise exceptions.AuthenticationFailed(msg)
elif len(auth) > 2:
msg = _("Invalid token header. Token string should not contain spaces.")
msg = _('Invalid token header. Token string should not contain spaces.')
raise exceptions.AuthenticationFailed(msg)
return self.authenticate_credentials(auth[1])
@ -165,10 +165,10 @@ class TokenAuthentication(BaseAuthentication):
try:
token = self.model.objects.get(key=key)
except self.model.DoesNotExist:
raise exceptions.AuthenticationFailed(_("Invalid token"))
raise exceptions.AuthenticationFailed(_('Invalid token.'))
if not token.user.is_active:
raise exceptions.AuthenticationFailed(_("User inactive or deleted"))
raise exceptions.AuthenticationFailed(_('User inactive or deleted.'))
return (token.user, token)

View File

@ -17,13 +17,13 @@ class AuthTokenSerializer(serializers.Serializer):
if user:
if not user.is_active:
msg = _("User account is disabled.")
msg = _('User account is disabled.')
raise exceptions.ValidationError(msg)
else:
msg = _("Unable to log in with provided credentials.")
msg = _('Unable to log in with provided credentials.')
raise exceptions.ValidationError(msg)
else:
msg = _("Must include \"username\" and \"password\"")
msg = _('Must include "username" and "password".')
raise exceptions.ValidationError(msg)
attrs['user'] = user

View File

@ -35,7 +35,7 @@ class APIException(Exception):
Subclasses should provide `.status_code` and `.default_detail` properties.
"""
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
default_detail = _("A server error occurred.")
default_detail = _('A server error occurred.')
def __init__(self, detail=None):
if detail is not None:
@ -70,32 +70,32 @@ class ValidationError(APIException):
class ParseError(APIException):
status_code = status.HTTP_400_BAD_REQUEST
default_detail = _("Malformed request.")
default_detail = _('Malformed request.')
class AuthenticationFailed(APIException):
status_code = status.HTTP_401_UNAUTHORIZED
default_detail = _("Incorrect authentication credentials.")
default_detail = _('Incorrect authentication credentials.')
class NotAuthenticated(APIException):
status_code = status.HTTP_401_UNAUTHORIZED
default_detail = _("Authentication credentials were not provided.")
default_detail = _('Authentication credentials were not provided.')
class PermissionDenied(APIException):
status_code = status.HTTP_403_FORBIDDEN
default_detail = _("You do not have permission to perform this action.")
default_detail = _('You do not have permission to perform this action.')
class NotFound(APIException):
status_code = status.HTTP_404_NOT_FOUND
default_detail = _("Not found.")
default_detail = _('Not found.')
class MethodNotAllowed(APIException):
status_code = status.HTTP_405_METHOD_NOT_ALLOWED
default_detail = _("Method \"{method}\" not allowed.")
default_detail = _('Method "{method}" not allowed.')
def __init__(self, method, detail=None):
if detail is not None:
@ -106,7 +106,7 @@ class MethodNotAllowed(APIException):
class NotAcceptable(APIException):
status_code = status.HTTP_406_NOT_ACCEPTABLE
default_detail = _("Could not satisfy the request Accept header.")
default_detail = _('Could not satisfy the request Accept header.')
def __init__(self, detail=None, available_renderers=None):
if detail is not None:
@ -118,7 +118,7 @@ class NotAcceptable(APIException):
class UnsupportedMediaType(APIException):
status_code = status.HTTP_415_UNSUPPORTED_MEDIA_TYPE
default_detail = _("Unsupported media type \"{media_type}\" in request.")
default_detail = _('Unsupported media type "{media_type}" in request.')
def __init__(self, media_type, detail=None):
if detail is not None:
@ -131,9 +131,9 @@ class UnsupportedMediaType(APIException):
class Throttled(APIException):
status_code = status.HTTP_429_TOO_MANY_REQUESTS
default_detail = _("Request was throttled.")
extra_detail_singular = "Expected available in {wait} second."
extra_detail_plural = "Expected available in {wait} seconds."
default_detail = _('Request was throttled.')
extra_detail_singular = 'Expected available in {wait} second.'
extra_detail_plural = 'Expected available in {wait} seconds.'
def __init__(self, wait=None, detail=None):
if detail is not None:

View File

@ -149,8 +149,8 @@ class Field(object):
_creation_counter = 0
default_error_messages = {
'required': _("This field is required."),
'null': _("This field may not be null.")
'required': _('This field is required.'),
'null': _('This field may not be null.')
}
default_validators = []
default_empty_html = empty
@ -477,7 +477,7 @@ class Field(object):
class BooleanField(Field):
default_error_messages = {
'invalid': _("`{input}` is not a valid boolean.")
'invalid': _('`{input}` is not a valid boolean.')
}
default_empty_html = False
initial = False
@ -505,7 +505,7 @@ class BooleanField(Field):
class NullBooleanField(Field):
default_error_messages = {
'invalid': _("`{input}` is not a valid boolean.")
'invalid': _('`{input}` is not a valid boolean.')
}
initial = None
TRUE_VALUES = set(('t', 'T', 'true', 'True', 'TRUE', '1', 1, True))
@ -540,9 +540,9 @@ class NullBooleanField(Field):
class CharField(Field):
default_error_messages = {
'blank': _("This field may not be blank."),
'max_length': _("Ensure this field has no more than {max_length} characters."),
'min_length': _("Ensure this field has at least {min_length} characters.")
'blank': _('This field may not be blank.'),
'max_length': _('Ensure this field has no more than {max_length} characters.'),
'min_length': _('Ensure this field has at least {min_length} characters.')
}
initial = ''
coerce_blank_to_null = False
@ -584,7 +584,7 @@ class CharField(Field):
class EmailField(CharField):
default_error_messages = {
'invalid': _("Enter a valid email address.")
'invalid': _('Enter a valid email address.')
}
def __init__(self, **kwargs):
@ -601,7 +601,7 @@ class EmailField(CharField):
class RegexField(CharField):
default_error_messages = {
'invalid': _("This value does not match the required pattern.")
'invalid': _('This value does not match the required pattern.')
}
def __init__(self, regex, **kwargs):
@ -612,7 +612,7 @@ class RegexField(CharField):
class SlugField(CharField):
default_error_messages = {
'invalid': _("Enter a valid \"slug\" consisting of letters, numbers, underscores or hyphens.")
'invalid': _('Enter a valid "slug" consisting of letters, numbers, underscores or hyphens.')
}
def __init__(self, **kwargs):
@ -624,7 +624,7 @@ class SlugField(CharField):
class URLField(CharField):
default_error_messages = {
'invalid': _("Enter a valid URL.")
'invalid': _('Enter a valid URL.')
}
def __init__(self, **kwargs):
@ -637,10 +637,10 @@ class URLField(CharField):
class IntegerField(Field):
default_error_messages = {
'invalid': _("A valid integer is required."),
'max_value': _("Ensure this value is less than or equal to {max_value}."),
'min_value': _("Ensure this value is greater than or equal to {min_value}."),
'max_string_length': _("String value too large.")
'invalid': _('A valid integer is required.'),
'max_value': _('Ensure this value is less than or equal to {max_value}.'),
'min_value': _('Ensure this value is greater than or equal to {min_value}.'),
'max_string_length': _('String value too large.')
}
MAX_STRING_LENGTH = 1000 # Guard against malicious string inputs.
@ -671,10 +671,10 @@ class IntegerField(Field):
class FloatField(Field):
default_error_messages = {
'invalid': _("A valid number is required."),
'max_value': _("Ensure this value is less than or equal to {max_value}."),
'min_value': _("Ensure this value is greater than or equal to {min_value}."),
'max_string_length': _("String value too large.")
'invalid': _('A valid number is required.'),
'max_value': _('Ensure this value is less than or equal to {max_value}.'),
'min_value': _('Ensure this value is greater than or equal to {min_value}.'),
'max_string_length': _('String value too large.')
}
MAX_STRING_LENGTH = 1000 # Guard against malicious string inputs.
@ -704,13 +704,13 @@ class FloatField(Field):
class DecimalField(Field):
default_error_messages = {
'invalid': _("A valid number is required."),
'max_value': _("Ensure this value is less than or equal to {max_value}."),
'min_value': _("Ensure this value is greater than or equal to {min_value}."),
'max_digits': _("Ensure that there are no more than {max_digits} digits in total."),
'max_decimal_places': _("Ensure that there are no more than {max_decimal_places} decimal places."),
'max_whole_digits': _("Ensure that there are no more than {max_whole_digits} digits before the decimal point."),
'max_string_length': _("String value too large.")
'invalid': _('A valid number is required.'),
'max_value': _('Ensure this value is less than or equal to {max_value}.'),
'min_value': _('Ensure this value is greater than or equal to {min_value}.'),
'max_digits': _('Ensure that there are no more than {max_digits} digits in total.'),
'max_decimal_places': _('Ensure that there are no more than {max_decimal_places} decimal places.'),
'max_whole_digits': _('Ensure that there are no more than {max_whole_digits} digits before the decimal point.'),
'max_string_length': _('String value too large.')
}
MAX_STRING_LENGTH = 1000 # Guard against malicious string inputs.
@ -793,8 +793,8 @@ class DecimalField(Field):
class DateTimeField(Field):
default_error_messages = {
'invalid': _("Datetime has wrong format. Use one of these formats instead: {format}."),
'date': _("Expected a datetime but got a date."),
'invalid': _('Datetime has wrong format. Use one of these formats instead: {format}.'),
'date': _('Expected a datetime but got a date.'),
}
format = api_settings.DATETIME_FORMAT
input_formats = api_settings.DATETIME_INPUT_FORMATS
@ -858,8 +858,8 @@ class DateTimeField(Field):
class DateField(Field):
default_error_messages = {
'invalid': _("Date has wrong format. Use one of these formats instead: {format}."),
'datetime': _("Expected a date but got a datetime."),
'invalid': _('Date has wrong format. Use one of these formats instead: {format}.'),
'datetime': _('Expected a date but got a datetime.'),
}
format = api_settings.DATE_FORMAT
input_formats = api_settings.DATE_INPUT_FORMATS
@ -916,7 +916,7 @@ class DateField(Field):
class TimeField(Field):
default_error_messages = {
'invalid': _("Time has wrong format. Use one of these formats instead: {format}."),
'invalid': _('Time has wrong format. Use one of these formats instead: {format}.'),
}
format = api_settings.TIME_FORMAT
input_formats = api_settings.TIME_INPUT_FORMATS
@ -972,7 +972,7 @@ class TimeField(Field):
class ChoiceField(Field):
default_error_messages = {
'invalid_choice': _("`{input}` is not a valid choice.")
'invalid_choice': _('`{input}` is not a valid choice.')
}
def __init__(self, choices, **kwargs):
@ -1016,8 +1016,8 @@ class ChoiceField(Field):
class MultipleChoiceField(ChoiceField):
default_error_messages = {
'invalid_choice': _("`{input}` is not a valid choice."),
'not_a_list': _("Expected a list of items but got type `{input_type}`.")
'invalid_choice': _('`{input}` is not a valid choice.'),
'not_a_list': _('Expected a list of items but got type `{input_type}`.')
}
default_empty_html = []
@ -1047,11 +1047,11 @@ class MultipleChoiceField(ChoiceField):
class FileField(Field):
default_error_messages = {
'required': _("No file was submitted."),
'invalid': _("The submitted data was not a file. Check the encoding type on the form."),
'no_name': _("No filename could be determined."),
'empty': _("The submitted file is empty."),
'max_length': _("Ensure this filename has at most {max_length} characters (it has {length})."),
'required': _('No file was submitted.'),
'invalid': _('The submitted data was not a file. Check the encoding type on the form.'),
'no_name': _('No filename could be determined.'),
'empty': _('The submitted file is empty.'),
'max_length': _('Ensure this filename has at most {max_length} characters (it has {length}).'),
}
use_url = api_settings.UPLOADED_FILES_USE_URL
@ -1118,7 +1118,7 @@ class ListField(Field):
child = None
initial = []
default_error_messages = {
'not_a_list': _("Expected a list of items but got type `{input_type}`.")
'not_a_list': _('Expected a list of items but got type `{input_type}`.')
}
def __init__(self, *args, **kwargs):
@ -1249,7 +1249,7 @@ class ModelField(Field):
that do not have a serializer field to be mapped to.
"""
default_error_messages = {
'max_length': _("Ensure this field has no more than {max_length} characters."),
'max_length': _('Ensure this field has no more than {max_length} characters.'),
}
def __init__(self, model_field, **kwargs):

View File

@ -120,12 +120,12 @@ class GenericAPIView(views.APIView):
if page == 'last':
page_number = paginator.num_pages
else:
raise NotFound(_("Choose a valid page number. Page numbers must be a whole number, or must be the string \"last\"."))
raise NotFound(_('Choose a valid page number. Page numbers must be a whole number, or must be the string "last".'))
try:
page = paginator.page(page_number)
except InvalidPage as exc:
error_format = _("Invalid page \"{page_number}\": {message}.")
error_format = _('Invalid page "{page_number}": {message}.')
raise NotFound(error_format.format(
page_number=page_number, message=six.text_type(exc)
))

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-01-07 11:58+0000\n"
"POT-Creation-Date: 2015-01-07 12:28+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -42,11 +42,11 @@ msgid "Invalid token header. Token string should not contain spaces."
msgstr ""
#: authentication.py:168
msgid "Invalid token"
msgid "Invalid token."
msgstr ""
#: authentication.py:171
msgid "User inactive or deleted"
msgid "User inactive or deleted."
msgstr ""
#: authtoken/serializers.py:20
@ -58,7 +58,7 @@ msgid "Unable to log in with provided credentials."
msgstr ""
#: authtoken/serializers.py:26
msgid "Must include \"username\" and \"password\""
msgid "Must include \"username\" and \"password\"."
msgstr ""
#: exceptions.py:38
@ -86,7 +86,7 @@ msgid "Not found."
msgstr ""
#: exceptions.py:98
msgid "Method '{method}' not allowed."
msgid "Method \"{method}\" not allowed."
msgstr ""
#: exceptions.py:109
@ -94,7 +94,7 @@ msgid "Could not satisfy the request Accept header."
msgstr ""
#: exceptions.py:121
msgid "Unsupported media type '{media_type}' in request."
msgid "Unsupported media type \"{media_type}\" in request."
msgstr ""
#: exceptions.py:134
@ -136,7 +136,8 @@ msgstr ""
#: fields.py:615
msgid ""
"Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens."
"Enter a valid \"slug\" consisting of letters, numbers, underscores or "
"hyphens."
msgstr ""
#: fields.py:627
@ -235,15 +236,15 @@ msgstr ""
#: generics.py:123
msgid ""
"Choose a valid page number. Page numbers must be a whole number, or must be "
"the string 'last'."
"the string \"last\"."
msgstr ""
#: generics.py:128
msgid "Invalid page ({page_number}): {message}."
msgid "Invalid page \"{page_number}\": {message}."
msgstr ""
#: relations.py:132
msgid "Invalid pk '{pk_value}' - object does not exist."
msgid "Invalid pk \"{pk_value}\" - object does not exist."
msgstr ""
#: relations.py:133
@ -299,7 +300,7 @@ msgid "This field must be unique for the \"{date_field}\" year."
msgstr ""
#: versioning.py:39
msgid "Invalid version in 'Accept' header."
msgid "Invalid version in \"Accept\" header."
msgstr ""
#: versioning.py:70 versioning.py:112

View File

@ -128,9 +128,9 @@ class StringRelatedField(RelatedField):
class PrimaryKeyRelatedField(RelatedField):
default_error_messages = {
'required': _("This field is required."),
'does_not_exist': _("Invalid pk \"{pk_value}\" - object does not exist."),
'incorrect_type': _("Incorrect type. Expected pk value, received {data_type}."),
'required': _('This field is required.'),
'does_not_exist': _('Invalid pk "{pk_value}" - object does not exist.'),
'incorrect_type': _('Incorrect type. Expected pk value, received {data_type}.'),
}
def use_pk_only_optimization(self):
@ -152,11 +152,11 @@ class HyperlinkedRelatedField(RelatedField):
lookup_field = 'pk'
default_error_messages = {
'required': _("This field is required."),
'no_match': _("Invalid hyperlink - No URL match."),
'incorrect_match': _("Invalid hyperlink - Incorrect URL match."),
'does_not_exist': _("Invalid hyperlink - Object does not exist."),
'incorrect_type': _("Incorrect type. Expected URL string, received {data_type}."),
'required': _('This field is required.'),
'no_match': _('Invalid hyperlink - No URL match.'),
'incorrect_match': _('Invalid hyperlink - Incorrect URL match.'),
'does_not_exist': _('Invalid hyperlink - Object does not exist.'),
'incorrect_type': _('Incorrect type. Expected URL string, received {data_type}.'),
}
def __init__(self, view_name=None, **kwargs):
@ -291,8 +291,8 @@ class SlugRelatedField(RelatedField):
"""
default_error_messages = {
'does_not_exist': _("Object with {slug_name}={value} does not exist."),
'invalid': _("Invalid value."),
'does_not_exist': _('Object with {slug_name}={value} does not exist.'),
'invalid': _('Invalid value.'),
}
def __init__(self, slug_field=None, **kwargs):

View File

@ -296,7 +296,7 @@ def get_validation_error_detail(exc):
@six.add_metaclass(SerializerMetaclass)
class Serializer(BaseSerializer):
default_error_messages = {
'invalid': _("Invalid data. Expected a dictionary, but got {datatype}.")
'invalid': _('Invalid data. Expected a dictionary, but got {datatype}.')
}
@property
@ -473,7 +473,7 @@ class ListSerializer(BaseSerializer):
many = True
default_error_messages = {
'not_a_list': _("Expected a list of items but got type `{input_type}`.")
'not_a_list': _('Expected a list of items but got type `{input_type}`.')
}
def __init__(self, *args, **kwargs):

View File

@ -19,7 +19,7 @@ class UniqueValidator:
Should be applied to an individual field on the serializer.
"""
message = _("This field must be unique.")
message = _('This field must be unique.')
def __init__(self, queryset, message=None):
self.queryset = queryset
@ -73,8 +73,8 @@ class UniqueTogetherValidator:
Should be applied to the serializer class, not to an individual field.
"""
message = _("The fields {field_names} must make a unique set.")
missing_message = _("This field is required.")
message = _('The fields {field_names} must make a unique set.')
missing_message = _('This field is required.')
def __init__(self, queryset, fields, message=None):
self.queryset = queryset
@ -152,7 +152,7 @@ class UniqueTogetherValidator:
class BaseUniqueForValidator:
message = None
missing_message = _("This field is required.")
missing_message = _('This field is required.')
def __init__(self, queryset, field, date_field, message=None):
self.queryset = queryset
@ -216,7 +216,7 @@ class BaseUniqueForValidator:
class UniqueForDateValidator(BaseUniqueForValidator):
message = _("This field must be unique for the \"{date_field}\" date.")
message = _('This field must be unique for the "{date_field}" date.')
def filter_queryset(self, attrs, queryset):
value = attrs[self.field]
@ -231,7 +231,7 @@ class UniqueForDateValidator(BaseUniqueForValidator):
class UniqueForMonthValidator(BaseUniqueForValidator):
message = _("This field must be unique for the \"{date_field}\" month.")
message = _('This field must be unique for the "{date_field}" month.')
def filter_queryset(self, attrs, queryset):
value = attrs[self.field]
@ -244,7 +244,7 @@ class UniqueForMonthValidator(BaseUniqueForValidator):
class UniqueForYearValidator(BaseUniqueForValidator):
message = _("This field must be unique for the \"{date_field}\" year.")
message = _('This field must be unique for the "{date_field}" year.')
def filter_queryset(self, attrs, queryset):
value = attrs[self.field]

View File

@ -36,7 +36,7 @@ class AcceptHeaderVersioning(BaseVersioning):
Host: example.com
Accept: application/json; version=1.0
"""
invalid_version_message = _("Invalid version in \"Accept\" header.")
invalid_version_message = _('Invalid version in "Accept" header.')
def determine_version(self, request, *args, **kwargs):
media_type = _MediaType(request.accepted_media_type)
@ -67,7 +67,7 @@ class URLPathVersioning(BaseVersioning):
Host: example.com
Accept: application/json
"""
invalid_version_message = _("Invalid version in URL path.")
invalid_version_message = _('Invalid version in URL path.')
def determine_version(self, request, *args, **kwargs):
version = kwargs.get(self.version_param, self.default_version)
@ -109,7 +109,7 @@ class NamespaceVersioning(BaseVersioning):
Host: example.com
Accept: application/json
"""
invalid_version_message = _("Invalid version in URL path.")
invalid_version_message = _('Invalid version in URL path.')
def determine_version(self, request, *args, **kwargs):
resolver_match = getattr(request, 'resolver_match', None)
@ -135,7 +135,7 @@ class HostNameVersioning(BaseVersioning):
Accept: application/json
"""
hostname_regex = re.compile(r'^([a-zA-Z0-9]+)\.[a-zA-Z0-9]+\.[a-zA-Z0-9]+$')
invalid_version_message = _("Invalid version in hostname.")
invalid_version_message = _('Invalid version in hostname.')
def determine_version(self, request, *args, **kwargs):
hostname, seperator, port = request.get_host().partition(':')
@ -157,7 +157,7 @@ class QueryParameterVersioning(BaseVersioning):
Host: example.com
Accept: application/json
"""
invalid_version_message = _("Invalid version in query parameter.")
invalid_version_message = _('Invalid version in query parameter.')
def determine_version(self, request, *args, **kwargs):
version = request.query_params.get(self.version_param)

View File

@ -439,7 +439,7 @@ class TestSlugField(FieldValues):
'slug-99': 'slug-99',
}
invalid_inputs = {
'slug 99': ["Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens."]
'slug 99': ['Enter a valid "slug" consisting of letters, numbers, underscores or hyphens.']
}
outputs = {}
field = serializers.SlugField()

View File

@ -117,7 +117,7 @@ class TestRootView(TestCase):
with self.assertNumQueries(0):
response = self.view(request).render()
self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)
self.assertEqual(response.data, {"detail": "Method 'PUT' not allowed."})
self.assertEqual(response.data, {"detail": 'Method "PUT" not allowed.'})
def test_delete_root_view(self):
"""
@ -127,7 +127,7 @@ class TestRootView(TestCase):
with self.assertNumQueries(0):
response = self.view(request).render()
self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)
self.assertEqual(response.data, {"detail": "Method 'DELETE' not allowed."})
self.assertEqual(response.data, {"detail": 'Method "DELETE" not allowed.'})
def test_post_cannot_set_id(self):
"""
@ -181,7 +181,7 @@ class TestInstanceView(TestCase):
with self.assertNumQueries(0):
response = self.view(request).render()
self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)
self.assertEqual(response.data, {"detail": "Method 'POST' not allowed."})
self.assertEqual(response.data, {"detail": 'Method "POST" not allowed.'})
def test_put_instance_view(self):
"""

View File

@ -33,7 +33,7 @@ class TestPrimaryKeyRelatedField(APISimpleTestCase):
with pytest.raises(serializers.ValidationError) as excinfo:
self.field.to_internal_value(4)
msg = excinfo.value.detail[0]
assert msg == "Invalid pk '4' - object does not exist."
assert msg == 'Invalid pk "4" - object does not exist.'
def test_pk_related_lookup_invalid_type(self):
with pytest.raises(serializers.ValidationError) as excinfo: