Convert encoders tests to pytest style (#4796)

This commit is contained in:
Artem Muterko 2017-01-08 18:10:47 +02:00 committed by Tom Christie
parent 4dd71d68d2
commit 99d57df990

View File

@ -2,6 +2,7 @@ from datetime import date, datetime, timedelta, tzinfo
from decimal import Decimal
from uuid import uuid4
import pytest
from django.test import TestCase
from rest_framework.compat import coreapi
@ -57,7 +58,7 @@ class JSONEncoderTests(TestCase):
current_time = datetime.now().time()
current_time = current_time.replace(tzinfo=UTC())
with self.assertRaises(ValueError):
with pytest.raises(ValueError):
self.encoder.default(current_time)
def test_encode_date(self):
@ -85,8 +86,8 @@ class JSONEncoderTests(TestCase):
"""
Tests encoding a coreapi objects raises proper error
"""
with self.assertRaises(RuntimeError):
with pytest.raises(RuntimeError):
self.encoder.default(coreapi.Document())
with self.assertRaises(RuntimeError):
with pytest.raises(RuntimeError):
self.encoder.default(coreapi.Error())