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
6e30dc75
Commit
6e30dc75
authored
Nov 30, 2016
by
Xavier Ordoquy
Committed by
GitHub
Nov 30, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4722 from auvipy/pytest7
converted descriptions and ecoders test asserts to pytest
parents
01cd0915
7e8b01db
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
tests/test_description.py
+5
-5
tests/test_encoders.py
+6
-6
No files found.
tests/test_description.py
View file @
6e30dc75
...
@@ -60,7 +60,7 @@ class TestViewNamesAndDescriptions(TestCase):
...
@@ -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):
...
@@ -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):
...
@@ -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):
...
@@ -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):
...
@@ -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
():
...
...
tests/test_encoders.py
View file @
6e30dc75
...
@@ -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