def test_ddt_data_unicode():
"""
Test that unicode strings are converted to function names correctly
"""
def hello():
pass
# We test unicode support separately for python 2 and 3
if six.PY2:
@ddt
class Mytest(object):
@data(u'ascii', u'non-ascii-\N{SNOWMAN}', {u'\N{SNOWMAN}': 'data'})
def test_hello(self, val):
pass
assert_is_not_none(getattr(Mytest, 'test_hello_1_ascii'))
assert_is_not_none(getattr(Mytest, 'test_hello_2_non_ascii__u2603'))
assert_is_not_none(getattr(Mytest, 'test_hello_3'))
elif six.PY3:
@ddt
class Mytest(object):
@data('ascii', 'non-ascii-\N{SNOWMAN}', {'\N{SNOWMAN}': 'data'})
def test_hello(self, val):
pass
assert_is_not_none(getattr(Mytest, 'test_hello_1_ascii'))
assert_is_not_none(getattr(Mytest, 'test_hello_2_non_ascii__'))
assert_is_not_none(getattr(Mytest, 'test_hello_3'))
评论列表
文章目录