Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pystache_custom
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
OpenEdx
pystache_custom
Commits
b06ea722
Commit
b06ea722
authored
Apr 08, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made a test_context pass in Python 3.
parent
c414a5ca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
22 deletions
+19
-22
pystache/tests/test_context.py
+19
-22
No files found.
pystache/tests/test_context.py
View file @
b06ea722
...
...
@@ -85,9 +85,11 @@ class GetValueTests(unittest.TestCase, AssertIsMixin):
Test that dictionary attributes are not checked.
"""
item
=
{}
attr_name
=
"keys"
self
.
assertEqual
(
getattr
(
item
,
attr_name
)(),
[])
item
=
{
1
:
2
,
3
:
4
}
# I was not able to find a "public" attribute of dict that is
# the same across Python 2/3.
attr_name
=
"__len__"
self
.
assertEqual
(
getattr
(
item
,
attr_name
)(),
2
)
self
.
assertNotFound
(
item
,
attr_name
)
def
test_dictionary__dict_subclass
(
self
):
...
...
@@ -154,25 +156,20 @@ class GetValueTests(unittest.TestCase, AssertIsMixin):
"""
class
MyInt
(
int
):
pass
item1
=
MyInt
(
10
)
item2
=
10
try
:
item2
.
real
except
AttributeError
:
# Then skip this unit test. The numeric type hierarchy was
# added only in Python 2.6, in which case integers inherit
# from complex numbers the "real" attribute, etc:
#
# http://docs.python.org/library/numbers.html
#
return
self
.
assertEqual
(
item1
.
real
,
10
)
self
.
assertEqual
(
item2
.
real
,
10
)
self
.
assertEqual
(
_get_value
(
item1
,
'real'
),
10
)
self
.
assertNotFound
(
item2
,
'real'
)
cust_int
=
MyInt
(
10
)
pure_int
=
10
# We have to use a built-in method like __neg__ because "public"
# attributes like "real" were not added to Python until Python 2.6,
# when the numeric type hierarchy was added:
#
# http://docs.python.org/library/numbers.html
#
self
.
assertEqual
(
cust_int
.
__neg__
(),
-
10
)
self
.
assertEqual
(
pure_int
.
__neg__
(),
-
10
)
self
.
assertEqual
(
_get_value
(
cust_int
,
'__neg__'
),
-
10
)
self
.
assertNotFound
(
pure_int
,
'__neg__'
)
def
test_built_in_type__string
(
self
):
"""
...
...
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