• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python _compat.unichr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中redis._compat.unichr函数的典型用法代码示例。如果您正苦于以下问题:Python unichr函数的具体用法?Python unichr怎么用?Python unichr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了unichr函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_unicode_pattern_message_handler

 def test_unicode_pattern_message_handler(self, r):
     p = r.pubsub(ignore_subscribe_messages=True)
     pattern = u('uni') + unichr(4456) + u('*')
     channel = u('uni') + unichr(4456) + u('code')
     p.psubscribe(**{pattern: self.message_handler})
     assert r.publish(channel, 'test message') == 1
     assert wait_for_message(p) is None
     assert self.message == make_message('pmessage', channel,
                                         'test message', pattern=pattern)
开发者ID:AbdullahAli,项目名称:redis-py,代码行数:9,代码来源:test_pubsub.py


示例2: test_simple_encoding

 def test_simple_encoding(self):
     unicode_string = unichr(3456) + u('abcd') + unichr(3421)
     self.client.set('unicode-string', unicode_string)
     cached_val = self.client.get('unicode-string')
     self.assertEquals(
         unicode.__name__, type(cached_val).__name__,
         'Cache returned value with type "%s", expected "%s"' %
         (type(cached_val).__name__, unicode.__name__))
     self.assertEqual(unicode_string, cached_val)
开发者ID:Argger,项目名称:redis-py,代码行数:9,代码来源:encoding.py


示例3: test_get_and_set

 def test_get_and_set(self, r):
     # get and set can't be tested independently of each other
     assert r.get("a") is None
     byte_string = b("value")
     integer = 5
     unicode_string = unichr(3456) + u("abcd") + unichr(3421)
     assert r.set("byte_string", byte_string)
     assert r.set("integer", 5)
     assert r.set("unicode_string", unicode_string)
     assert r.get("byte_string") == byte_string
     assert r.get("integer") == b(str(integer))
     assert r.get("unicode_string").decode("utf-8") == unicode_string
开发者ID:Krave-n,项目名称:redis-py,代码行数:12,代码来源:test_commands.py


示例4: test_exec_error_in_no_transaction_pipeline_unicode_command

    def test_exec_error_in_no_transaction_pipeline_unicode_command(self, r):
        key = unichr(3456) + u('abcd') + unichr(3421)
        r[key] = 1
        with r.pipeline(transaction=False) as pipe:
            pipe.llen(key)
            pipe.expire(key, 100)

            with pytest.raises(ResponseError) as ex:
                pipe.execute()

            expected = unicode('Command # 1 (LLEN {0}) of pipeline caused error: ').format(key)
            assert unicode(ex.value).startswith(expected)

        assert r[key] == b('1')
开发者ID:Grokzen,项目名称:redis-py-cluster,代码行数:14,代码来源:test_pipeline.py


示例5: test_exec_error_in_no_transaction_pipeline_unicode_command

    def test_exec_error_in_no_transaction_pipeline_unicode_command(self):
        key = unichr(3456) + u('abcd') + unichr(3421)
        self.rc[key] = 1
        with self.rc.pipeline(transaction=False) as pipe:
            pipe.llen(key)
            pipe.expire(key, 100)

            with pytest.raises(redis.ResponseError) as ex:
                pipe.execute()
            print ex.value
            expected = unicode('Command # 1 (LLEN %s) of pipeline caused '
                               'error: ') % key
            assert unicode(ex.value).startswith(expected)

        assert self.rc[key] == b('1')
开发者ID:kevinsu,项目名称:redis-py-multi-node,代码行数:15,代码来源:test_pipeline.py


示例6: test_exec_error_in_no_transaction_pipeline_unicode_command

    def test_exec_error_in_no_transaction_pipeline_unicode_command(self):
        key = unichr(3456) + u('abcd') + unichr(3421)
        yield self.client.set(key, 1)
        with self.client.pipeline(transaction=False) as pipe:
            pipe.llen(key)
            pipe.expire(key, 100)

            expected = unicode('Command # 1 (LLEN %s) of pipeline caused '
                               'error: ') % key
            try :
                yield pipe.execute()
            except redis.ResponseError as ex:
                self.assertTrue(unicode(ex).startswith(expected))

        res = yield self.client.get(key)
        self.assertEqual(res, b('1'))
开发者ID:BoneLee,项目名称:FBT,代码行数:16,代码来源:test_pipeline.py


示例7: test_slowlog_get

    def test_slowlog_get(self, r, slowlog):
        assert r.slowlog_reset()
        unicode_string = unichr(3456) + u('abcd') + unichr(3421)
        r.get(unicode_string)
        slowlog = r.slowlog_get()
        assert isinstance(slowlog, list)
        assert len(slowlog) == 2
        get_command = slowlog[0]
        assert isinstance(get_command['start_time'], int)
        assert isinstance(get_command['duration'], int)
        assert get_command['command'] == \
            b(' ').join((b('GET'), unicode_string.encode('utf-8')))

        slowlog_reset_command = slowlog[1]
        assert isinstance(slowlog_reset_command['start_time'], int)
        assert isinstance(slowlog_reset_command['duration'], int)
        assert slowlog_reset_command['command'] == b('SLOWLOG RESET')
开发者ID:ccgillett,项目名称:redis-py,代码行数:17,代码来源:test_commands.py


示例8: test_unicode_channel_message_handler

 def test_unicode_channel_message_handler(self, r):
     p = r.pubsub(ignore_subscribe_messages=True)
     channel = u('uni') + unichr(4456) + u('code')
     channels = {channel: self.message_handler}
     p.subscribe(**channels)
     assert r.publish(channel, 'test message') == 1
     assert wait_for_message(p) is None
     assert self.message == make_message('message', channel, 'test message')
开发者ID:AbdullahAli,项目名称:redis-py,代码行数:8,代码来源:test_pubsub.py


示例9: test_get_and_set

 def test_get_and_set(self):
     # get and set can't be tested independently of each other
     r = self.r
     res = yield r.get('a')
     self.assertTrue(res is None)
     byte_string = b('value')
     integer = 5
     unicode_string = unichr(3456) + u('abcd') + unichr(3421)
     yield r.set('byte_string', byte_string)
     yield r.set('integer', 5)
     yield r.set('unicode_string', unicode_string)
     res = yield r.get('byte_string')
     self.assertEqual(res, byte_string)
     res = yield r.get('integer')
     self.assertEqual(res, b(str(integer)))
     res = yield r.get('unicode_string')
     self.assertEqual(res.decode('utf-8'), unicode_string)
开发者ID:BoneLee,项目名称:FBT,代码行数:17,代码来源:test_basic.py


示例10: make_subscribe_test_data

def make_subscribe_test_data(pubsub, type):
    if type == 'channel':
        return {
            'p': pubsub,
            'sub_type': 'subscribe',
            'unsub_type': 'unsubscribe',
            'sub_func': pubsub.subscribe,
            'unsub_func': pubsub.unsubscribe,
            'keys': ['foo', 'bar', u('uni') + unichr(4456) + u('code')]
        }
    elif type == 'pattern':
        return {
            'p': pubsub,
            'sub_type': 'psubscribe',
            'unsub_type': 'punsubscribe',
            'sub_func': pubsub.psubscribe,
            'unsub_func': pubsub.punsubscribe,
            'keys': ['f*', 'b*', u('uni') + unichr(4456) + u('*')]
        }
    assert False, 'invalid subscribe type: %s' % type
开发者ID:AbdullahAli,项目名称:redis-py,代码行数:20,代码来源:test_pubsub.py


示例11: test_slowlog_get

    def test_slowlog_get(self, r, slowlog):
        assert r.slowlog_reset()
        unicode_string = unichr(3456) + u('abcd') + unichr(3421)
        r.get(unicode_string)
        slowlog = r.slowlog_get()
        assert isinstance(slowlog, list)
        commands = [log['command'] for log in slowlog]

        get_command = b(' ').join((b('GET'), unicode_string.encode('utf-8')))
        assert get_command in commands
        assert b('SLOWLOG RESET') in commands
        # the order should be ['GET <uni string>', 'SLOWLOG RESET'],
        # but if other clients are executing commands at the same time, there
        # could be commands, before, between, or after, so just check that
        # the two we care about are in the appropriate order.
        assert commands.index(get_command) < commands.index(b('SLOWLOG RESET'))

        # make sure other attributes are typed correctly
        assert isinstance(slowlog[0]['start_time'], int)
        assert isinstance(slowlog[0]['duration'], int)
开发者ID:AlfiyaZi,项目名称:redis-py,代码行数:20,代码来源:test_commands.py


示例12: test_slowlog_get

    def test_slowlog_get(self, r):
        # fail on purpose on travis
        assert [
            r.config_get('slowlog-log-slower-than'),
            r.config_get('slowlog-max-len')] == [-10, -10]
        assert r.slowlog_reset()
        unicode_string = unichr(3456) + u('abcd') + unichr(3421)
        r.get(unicode_string)
        slowlog = r.slowlog_get()
        assert isinstance(slowlog, list)
        assert len(slowlog) == 2
        get_command = slowlog[0]
        assert isinstance(get_command['start_time'], int)
        assert isinstance(get_command['duration'], int)
        assert get_command['command'] == \
            b(' ').join((b('GET'), unicode_string.encode('utf-8')))

        slowlog_reset_command = slowlog[1]
        assert isinstance(slowlog_reset_command['start_time'], int)
        assert isinstance(slowlog_reset_command['duration'], int)
        assert slowlog_reset_command['command'] == b('SLOWLOG RESET')
开发者ID:thinkroth,项目名称:redis-py,代码行数:21,代码来源:test_commands.py


示例13: test_object_value

 def test_object_value(self, r):
     unicode_string = unichr(3456) + u('abcd') + unichr(3421)
     r['unicode-string'] = Exception(unicode_string)
     cached_val = r['unicode-string']
     assert isinstance(cached_val, unicode)
     assert unicode_string == cached_val
开发者ID:343829084,项目名称:redis-py,代码行数:6,代码来源:test_encoding.py


示例14: test_list_encoding

 def test_list_encoding(self, r):
     unicode_string = unichr(3456) + u('abcd') + unichr(3421)
     result = [unicode_string, unicode_string, unicode_string]
     r.rpush('a', *result)
     assert r.lrange('a', 0, -1) == result
开发者ID:573719929,项目名称:redis-py,代码行数:5,代码来源:test_encoding.py


示例15: test_simple_encoding

 def test_simple_encoding(self, r):
     unicode_string = unichr(3456) + u('abcd') + unichr(3421)
     r['unicode-string'] = unicode_string
     cached_val = r['unicode-string']
     assert isinstance(cached_val, unicode)
     assert unicode_string == cached_val
开发者ID:573719929,项目名称:redis-py,代码行数:6,代码来源:test_encoding.py


示例16: test_list_encoding

 def test_list_encoding(self):
     unicode_string = unichr(3456) + u("abcd") + unichr(3421)
     result = [unicode_string, unicode_string, unicode_string]
     for i in range(len(result)):
         self.client.rpush("a", unicode_string)
     self.assertEquals(self.client.lrange("a", 0, -1), result)
开发者ID:marolf101x,项目名称:linuxcnc,代码行数:6,代码来源:encoding.py



注:本文中的redis._compat.unichr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python _compat.unicode函数代码示例发布时间:2022-05-27
下一篇:
Python loader.CommandLoader类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap