test_functional.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:deb-python-ddt 作者: openstack 项目源码 文件源码
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'))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号