Skip to content

Commit 6e30dc7

Browse files
authored
Merge pull request encode#4722 from auvipy/pytest7
converted descriptions and ecoders test asserts to pytest
2 parents 01cd091 + 7e8b01d commit 6e30dc7

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

tests/test_description.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_view_name_uses_class_name(self):
6060
"""
6161
class MockView(APIView):
6262
pass
63-
self.assertEqual(MockView().get_view_name(), 'Mock')
63+
assert MockView().get_view_name() == 'Mock'
6464

6565
def test_view_description_uses_docstring(self):
6666
"""Ensure view descriptions are based on the docstring."""
@@ -80,7 +80,7 @@ class MockView(APIView):
8080
8181
# hash style header #"""
8282

83-
self.assertEqual(MockView().get_view_description(), DESCRIPTION)
83+
assert MockView().get_view_description() == DESCRIPTION
8484

8585
def test_view_description_can_be_empty(self):
8686
"""
@@ -89,7 +89,7 @@ def test_view_description_can_be_empty(self):
8989
"""
9090
class MockView(APIView):
9191
pass
92-
self.assertEqual(MockView().get_view_description(), '')
92+
assert MockView().get_view_description() == ''
9393

9494
def test_view_description_can_be_promise(self):
9595
"""
@@ -111,7 +111,7 @@ def __str__(self):
111111
class MockView(APIView):
112112
__doc__ = MockLazyStr("a gettext string")
113113

114-
self.assertEqual(MockView().get_view_description(), 'a gettext string')
114+
assert MockView().get_view_description() == 'a gettext string'
115115

116116
def test_markdown(self):
117117
"""
@@ -120,7 +120,7 @@ def test_markdown(self):
120120
if apply_markdown:
121121
gte_21_match = apply_markdown(DESCRIPTION) == MARKED_DOWN_gte_21
122122
lt_21_match = apply_markdown(DESCRIPTION) == MARKED_DOWN_lt_21
123-
self.assertTrue(gte_21_match or lt_21_match)
123+
assert gte_21_match or lt_21_match
124124

125125

126126
def test_dedent_tabs():

tests/test_encoders.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ def test_encode_decimal(self):
2020
Tests encoding a decimal
2121
"""
2222
d = Decimal(3.14)
23-
self.assertEqual(d, float(d))
23+
assert d == float(d)
2424

2525
def test_encode_datetime(self):
2626
"""
2727
Tests encoding a datetime object
2828
"""
2929
current_time = datetime.now()
30-
self.assertEqual(self.encoder.default(current_time), current_time.isoformat())
30+
assert self.encoder.default(current_time) == current_time.isoformat()
3131

3232
def test_encode_time(self):
3333
"""
3434
Tests encoding a timezone
3535
"""
3636
current_time = datetime.now().time()
37-
self.assertEqual(self.encoder.default(current_time), current_time.isoformat()[:12])
37+
assert self.encoder.default(current_time) == current_time.isoformat()[:12]
3838

3939
def test_encode_time_tz(self):
4040
"""
@@ -64,18 +64,18 @@ def test_encode_date(self):
6464
Tests encoding a date object
6565
"""
6666
current_date = date.today()
67-
self.assertEqual(self.encoder.default(current_date), current_date.isoformat())
67+
assert self.encoder.default(current_date) == current_date.isoformat()
6868

6969
def test_encode_timedelta(self):
7070
"""
7171
Tests encoding a timedelta object
7272
"""
7373
delta = timedelta(hours=1)
74-
self.assertEqual(self.encoder.default(delta), str(delta.total_seconds()))
74+
assert self.encoder.default(delta) == str(delta.total_seconds())
7575

7676
def test_encode_uuid(self):
7777
"""
7878
Tests encoding a UUID object
7979
"""
8080
unique_id = uuid4()
81-
self.assertEqual(self.encoder.default(unique_id), str(unique_id))
81+
assert self.encoder.default(unique_id) == str(unique_id)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy