Convert encoders tests to pytest style

This commit is contained in:
Artem Muterko 2017-01-08 14:27:39 +02:00
parent e2c35920d1
commit 862b8d61ea

View File

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