Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env:

# command to install dependencies
install:
- pip install six tox-travis
- pip install tox-travis

# command to run tests
script:
Expand Down
4 changes: 2 additions & 2 deletions docs/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ framework, we'll use those as an example...::


class UserForm(ModelForm):
class Meta(object):
class Meta:
model = User
fields = ['username', 'first_name', 'last_name', 'email']

Expand Down Expand Up @@ -462,7 +462,7 @@ up your code into a validation method. An example of this might look like...::


class UserForm(ModelForm):
class Meta(object):
class Meta:
model = User
fields = ['username', 'first_name', 'last_name', 'email']

Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ a ``posts`` application, which has a model setup like so...::
posted_on = models.DateTimeField(auto_now_add=True)
updated_on = models.DateTimeField(auto_now=True)

class Meta(object):
class Meta:
ordering = ['-posted_on', 'title']

def __str__(self):
Expand Down
2 changes: 1 addition & 1 deletion examples/django/posts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Post(models.Model):
posted_on = models.DateTimeField(auto_now_add=True)
updated_on = models.DateTimeField(auto_now=True)

class Meta(object):
class Meta:
ordering = ['-posted_on', 'title']

def __str__(self):
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
six>=1.4.0
2 changes: 1 addition & 1 deletion restless/data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Data(object):
class Data:
def __init__(self, value, should_prepare=True, prepare_with=None):
"""
A container object that carries meta information about the data.
Expand Down
4 changes: 1 addition & 3 deletions restless/dj.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import six

from django.conf import settings
from django.conf.urls import url
from django.core.exceptions import ObjectDoesNotExist
Expand Down Expand Up @@ -82,7 +80,7 @@ def build_response(self, data, status=OK):
def build_error(self, err):
# A bit nicer behavior surrounding things that don't exist.
if isinstance(err, (ObjectDoesNotExist, Http404)):
err = NotFound(msg=six.text_type(err))
err = NotFound(msg=str(err))

return super(DjangoResource, self).build_error(err)

Expand Down
2 changes: 1 addition & 1 deletion restless/preparers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Preparer(object):
class Preparer:
"""
A plain preparation object which just passes through data.

Expand Down
2 changes: 1 addition & 1 deletion restless/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _wrapper(self, *args, **kwargs):
return _wrapper


class Resource(object):
class Resource:
"""
Defines a RESTful resource.

Expand Down
2 changes: 1 addition & 1 deletion restless/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from .utils import json, MoreTypesJSONEncoder


class Serializer(object):
class Serializer:
"""
A base serialization class.

Expand Down
2 changes: 1 addition & 1 deletion restless/tnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _method(self, *args, **kwargs):
yield self.resource_handler.handle(self.__resource_view_type__, *args, **kwargs)


class _BridgeMixin(object):
class _BridgeMixin:
"""
This mixin would pass tornado parameters to restless,
and helps to init a resource instance
Expand Down
3 changes: 0 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@
'restless',
],
requires=[
'six(>=1.4.0)',
],
install_requires=[
'six>=1.4.0',
],
tests_require=[
'mock',
'tox',
],
python_requires='!=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*',
Expand Down
14 changes: 5 additions & 9 deletions tests/fakes.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
import six


class FakeHttpRequest(object):
class FakeHttpRequest:
def __init__(self, method='GET', body='', **kwargs):
self.method = method.upper()
self.body = body
if six.PY3:
self.body = body.encode('utf-8')
self.body = body.encode('utf-8')
if self.method == 'GET':
self.GET = kwargs.get('get_request', {})


class FakeHttpResponse(object):
class FakeHttpResponse:
def __init__(self, body, content_type='text/html'):
self.body = body
self.content_type = content_type
self.status_code = 200


class FakeModel(object):
def __init__(self, **kwargs):
class FakeModel:
def __init_x_(self, **kwargs):
for k, v in kwargs.items():
setattr(self, k, v)
6 changes: 1 addition & 5 deletions tests/test_dj.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import unittest

try:
from http.client import responses
except ImportError:
from httplib import responses
from http.client import responses

try:
from django.conf import settings
Expand Down
2 changes: 1 addition & 1 deletion tests/test_preparers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
FieldsPreparer)


class InstaObj(object):
class InstaObj:
def __init__(self, **kwargs):
for k, v in kwargs.items():
setattr(self, k, v)
Expand Down
21 changes: 4 additions & 17 deletions tests/test_resources.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import six
import unittest

from restless.exceptions import HttpError, NotFound, MethodNotImplemented
Expand Down Expand Up @@ -54,28 +53,16 @@ def test_request_method(self):
self.assertEqual(self.res.request_method(), 'DELETE')

def test_request_body(self):
if six.PY3:
self.assertEqual(self.res.request_body(), b'')
else:
self.assertEqual(self.res.request_body(), '')
self.assertEqual(self.res.request_body(), b'')

self.res.request = FakeHttpRequest('POST', '{"hello": "world"}')
if six.PY3:
self.assertEqual(self.res.request_body(), b'{"hello": "world"}')
else:
self.assertEqual(self.res.request_body(), '{"hello": "world"}')
self.assertEqual(self.res.request_body(), b'{"hello": "world"}')

self.res.request = FakeHttpRequest('PUT', '{"hello": "world"}')
if six.PY3:
self.assertEqual(self.res.request_body(), b'{"hello": "world"}')
else:
self.assertEqual(self.res.request_body(), '{"hello": "world"}')
self.assertEqual(self.res.request_body(), b'{"hello": "world"}')

self.res.request = FakeHttpRequest('DELETE', '{}')
if six.PY3:
self.assertEqual(self.res.request_body(), b'{}')
else:
self.assertEqual(self.res.request_body(), '{}')
self.assertEqual(self.res.request_body(), b'{}')

def test_build_response(self):
resp = self.res.build_response('Hello, world!')
Expand Down
5 changes: 2 additions & 3 deletions tests/test_tnd.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import unittest
import socket
import six

from restless.utils import json
from restless.constants import UNAUTHORIZED


def _newer_or_equal_(v):
for i in six.moves.xrange(min(len(v), len(version_info))):
for i in range(min(len(v), len(version_info))):
expected, tnd = v[i], version_info[i]
if tnd > expected:
return True
Expand All @@ -19,7 +18,7 @@ def _newer_or_equal_(v):


def _equal_(v):
for i in six.moves.xrange(min(len(v), len(version_info))):
for i in range(min(len(v), len(version_info))):
if v[i] != version_info[i]:
return False
return True
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ basepython =
py39: python3.9
pypy: pypy
deps =
six
pytest
pytest-cov
WebOb>=1.3.1,<1.7
Expand Down