Skip to content

Commit 4239178

Browse files
author
Tim Csitkovics
committed
Make travis happy
1 parent 5ddf120 commit 4239178

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

example/tests/test_serializers.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@
2222
except ImportError:
2323
import mock
2424

25-
factory = APIRequestFactory()
25+
request_factory = APIRequestFactory()
2626
pytestmark = pytest.mark.django_db
2727

2828

2929
class TestResourceIdentifierObjectSerializer(TestCase):
3030
def setUp(self):
3131
self.blog = Blog.objects.create(name='Some Blog', tagline="It's a blog")
32-
self.now = timezone.now()
32+
now = timezone.now()
3333

3434
self.entry = Entry.objects.create(
3535
blog=self.blog,
3636
headline='headline',
3737
body_text='body_text',
38-
pub_date=self.now.date(),
39-
mod_date=self.now.date(),
38+
pub_date=now.date(),
39+
mod_date=now.date(),
4040
n_comments=0,
4141
n_pingbacks=0,
4242
rating=3
@@ -48,15 +48,16 @@ def setUp(self):
4848
)
4949

5050
def test_forward_relationship_not_loaded_when_not_included(self):
51-
with mock.patch('example.serializers.BlogSerializer.to_representation') as mocked_serializer:
51+
to_representation_method = 'example.serializers.BlogSerializer.to_representation'
52+
with mock.patch(to_representation_method) as mocked_serializer:
5253
class EntrySerializer(ModelSerializer):
5354
blog = BlogSerializer()
5455

5556
class Meta:
5657
model = Entry
5758
fields = '__all__'
5859

59-
request_without_includes = Request(factory.get('/'))
60+
request_without_includes = Request(request_factory.get('/'))
6061
serializer = EntrySerializer(context={'request': request_without_includes})
6162
serializer.to_representation(self.entry)
6263

@@ -70,7 +71,7 @@ class Meta:
7071
model = Entry
7172
fields = '__all__'
7273

73-
request_without_includes = Request(factory.get('/'))
74+
request_without_includes = Request(request_factory.get('/'))
7475
serializer = EntrySerializer(context={'request': request_without_includes})
7576
result = serializer.to_representation(self.entry)
7677

@@ -84,8 +85,8 @@ class Meta:
8485
('blog', OrderedDict([('type', 'blogs'), ('id', 1)])),
8586
('headline', 'headline'),
8687
('body_text', 'body_text'),
87-
('pub_date', DateField().to_representation(self.now.date())),
88-
('mod_date', DateField().to_representation(self.now.date())),
88+
('pub_date', DateField().to_representation(self.entry.pub_date)),
89+
('mod_date', DateField().to_representation(self.entry.mod_date)),
8990
('n_comments', 0),
9091
('n_pingbacks', 0),
9192
('rating', 3),

0 commit comments

Comments
 (0)