Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
7e8b01db
Commit
7e8b01db
authored
Nov 30, 2016
by
Asif Saifuddin Auvi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
converted asserts of encoders test to pytest
parent
9a3f8d9a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
tests/test_encoders.py
+6
-6
No files found.
tests/test_encoders.py
View file @
7e8b01db
...
@@ -20,21 +20,21 @@ class JSONEncoderTests(TestCase):
...
@@ -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):
...
@@ -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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment