Merge pull request #4722 from auvipy/pytest7

converted descriptions and ecoders test asserts to pytest
This commit is contained in:
Xavier Ordoquy 2016-11-30 12:00:29 +01:00 committed by GitHub
commit 6e30dc75e0
2 changed files with 11 additions and 11 deletions

View File

@ -60,7 +60,7 @@ class TestViewNamesAndDescriptions(TestCase):
""" """
class MockView(APIView): class MockView(APIView):
pass pass
self.assertEqual(MockView().get_view_name(), 'Mock') assert MockView().get_view_name() == 'Mock'
def test_view_description_uses_docstring(self): def test_view_description_uses_docstring(self):
"""Ensure view descriptions are based on the docstring.""" """Ensure view descriptions are based on the docstring."""
@ -80,7 +80,7 @@ class TestViewNamesAndDescriptions(TestCase):
# hash style header #""" # hash style header #"""
self.assertEqual(MockView().get_view_description(), DESCRIPTION) assert MockView().get_view_description() == DESCRIPTION
def test_view_description_can_be_empty(self): def test_view_description_can_be_empty(self):
""" """
@ -89,7 +89,7 @@ class TestViewNamesAndDescriptions(TestCase):
""" """
class MockView(APIView): class MockView(APIView):
pass pass
self.assertEqual(MockView().get_view_description(), '') assert MockView().get_view_description() == ''
def test_view_description_can_be_promise(self): def test_view_description_can_be_promise(self):
""" """
@ -111,7 +111,7 @@ class TestViewNamesAndDescriptions(TestCase):
class MockView(APIView): class MockView(APIView):
__doc__ = MockLazyStr("a gettext string") __doc__ = MockLazyStr("a gettext string")
self.assertEqual(MockView().get_view_description(), 'a gettext string') assert MockView().get_view_description() == 'a gettext string'
def test_markdown(self): def test_markdown(self):
""" """
@ -120,7 +120,7 @@ class TestViewNamesAndDescriptions(TestCase):
if apply_markdown: if apply_markdown:
gte_21_match = apply_markdown(DESCRIPTION) == MARKED_DOWN_gte_21 gte_21_match = apply_markdown(DESCRIPTION) == MARKED_DOWN_gte_21
lt_21_match = apply_markdown(DESCRIPTION) == MARKED_DOWN_lt_21 lt_21_match = apply_markdown(DESCRIPTION) == MARKED_DOWN_lt_21
self.assertTrue(gte_21_match or lt_21_match) assert gte_21_match or lt_21_match
def test_dedent_tabs(): def test_dedent_tabs():

View File

@ -20,21 +20,21 @@ class JSONEncoderTests(TestCase):
Tests encoding a decimal Tests encoding a decimal
""" """
d = Decimal(3.14) d = Decimal(3.14)
self.assertEqual(d, float(d)) assert d == float(d)
def test_encode_datetime(self): def test_encode_datetime(self):
""" """
Tests encoding a datetime object Tests encoding a datetime object
""" """
current_time = datetime.now() current_time = datetime.now()
self.assertEqual(self.encoder.default(current_time), current_time.isoformat()) assert self.encoder.default(current_time) == current_time.isoformat()
def test_encode_time(self): def test_encode_time(self):
""" """
Tests encoding a timezone Tests encoding a timezone
""" """
current_time = datetime.now().time() current_time = datetime.now().time()
self.assertEqual(self.encoder.default(current_time), current_time.isoformat()[:12]) assert self.encoder.default(current_time) == current_time.isoformat()[:12]
def test_encode_time_tz(self): def test_encode_time_tz(self):
""" """
@ -64,18 +64,18 @@ class JSONEncoderTests(TestCase):
Tests encoding a date object Tests encoding a date object
""" """
current_date = date.today() current_date = date.today()
self.assertEqual(self.encoder.default(current_date), current_date.isoformat()) assert self.encoder.default(current_date) == current_date.isoformat()
def test_encode_timedelta(self): def test_encode_timedelta(self):
""" """
Tests encoding a timedelta object Tests encoding a timedelta object
""" """
delta = timedelta(hours=1) delta = timedelta(hours=1)
self.assertEqual(self.encoder.default(delta), str(delta.total_seconds())) assert self.encoder.default(delta) == str(delta.total_seconds())
def test_encode_uuid(self): def test_encode_uuid(self):
""" """
Tests encoding a UUID object Tests encoding a UUID object
""" """
unique_id = uuid4() unique_id = uuid4()
self.assertEqual(self.encoder.default(unique_id), str(unique_id)) assert self.encoder.default(unique_id) == str(unique_id)