Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenStack
oslo
python-oslo.versionedobjects
Commits
578b23b6
Commit
578b23b6
authored
Jul 12, 2017
by
Jenkins
Committed by
Gerrit Code Review
Jul 12, 2017
Browse files
Merge "Add unit test for unicode in object __repr__"
parents
ffb349f9
36539df2
Changes
2
Hide whitespace changes
Inline
Side-by-side
oslo_versionedobjects/base.py
View file @
578b23b6
...
...
@@ -314,7 +314,7 @@ class VersionedObject(object):
field
.
stringify
(
getattr
(
self
,
name
))
or
'<?>'
))
for
name
,
field
in
sorted
(
self
.
fields
.
items
())]))
if
not
six
.
PY
3
:
if
six
.
PY
2
:
repr_str
=
encodeutils
.
safe_encode
(
repr_str
,
incoming
=
'utf-8'
)
return
repr_str
...
...
oslo_versionedobjects/tests/test_objects.py
View file @
578b23b6
...
...
@@ -1200,6 +1200,20 @@ class _TestObject(object):
obj2
=
MySensitiveObj
()
self
.
assertEqual
(
'MySensitiveObj(data=<?>)'
,
repr
(
obj2
))
def
test_obj_repr_unicode
(
self
):
obj
=
MyObj
(
bar
=
u
'
\u0191\u01A1\u01A1
'
)
# verify the unicode string has been encoded as ASCII if on python 2
if
six
.
PY2
:
self
.
assertEqual
(
"MyObj(bar='
\xc6\x91\xc6\xa1\xc6\xa1
',foo=<?>,"
"missing=<?>,mutable_default=<?>,readonly=<?>,"
"rel_object=<?>,rel_objects=<?>,timestamp=<?>)"
,
repr
(
obj
))
else
:
self
.
assertEqual
(
"MyObj(bar='
\u0191\u01A1\u01A1
',foo=<?>,"
"missing=<?>,mutable_default=<?>,readonly=<?>,"
"rel_object=<?>,rel_objects=<?>,timestamp=<?>)"
,
repr
(
obj
))
def
test_obj_make_obj_compatible_with_relationships
(
self
):
subobj
=
MyOwnedObject
(
baz
=
1
)
obj
=
MyObj
(
rel_object
=
subobj
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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