本文整理汇总了Python中mockredis.script.Script类的典型用法代码示例。如果您正苦于以下问题:Python Script类的具体用法?Python Script怎么用?Python Script使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Script类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_python_to_lua_none
def test_python_to_lua_none(self):
pval = None
lval = MockRedisScript._python_to_lua(pval)
is_null = """
function is_null(var1)
return var1 == nil
end
return is_null
"""
lua_is_null = self.lua.execute(is_null)
ok_(MockRedisScript._lua_to_python(lua_is_null(lval)))
开发者ID:RedisLabs,项目名称:mockredis,代码行数:11,代码来源:test_script.py
示例2: test_lua_to_python_bool
def test_lua_to_python_bool(self):
lval = self.lua.eval("true")
pval = MockRedisScript._lua_to_python(lval)
ok_(isinstance(pval, bool))
eq_(True, pval)
开发者ID:RedisLabs,项目名称:mockredis,代码行数:5,代码来源:test_script.py
示例3: test_lua_to_python_string
def test_lua_to_python_string(self):
lval = self.lua.eval('"somestring"')
pval = MockRedisScript._lua_to_python(lval)
ok_(isinstance(pval, str))
eq_("somestring", pval)
开发者ID:RedisLabs,项目名称:mockredis,代码行数:5,代码来源:test_script.py
示例4: test_lua_to_python_flota
def test_lua_to_python_flota(self):
lval = self.lua.eval("22.2")
pval = MockRedisScript._lua_to_python(lval)
ok_(isinstance(pval, float))
eq_(22.2, pval)
开发者ID:RedisLabs,项目名称:mockredis,代码行数:5,代码来源:test_script.py
示例5: test_lua_to_python_long
def test_lua_to_python_long(self):
lval = self.lua.eval("22")
pval = MockRedisScript._lua_to_python(lval)
ok_(isinstance(pval, long))
eq_(22, pval)
开发者ID:RedisLabs,项目名称:mockredis,代码行数:5,代码来源:test_script.py
示例6: test_lua_to_python_list
def test_lua_to_python_list(self):
lval = self.lua.eval('{"val1", "val2"}')
pval = MockredisScript._lua_to_python(lval)
self.assertIsInstance(pval, list)
self.assertEqual(["val1", "val2"], pval)
开发者ID:aim110,项目名称:mockredis,代码行数:5,代码来源:test_script.py
示例7: test_python_to_lua_float
def test_python_to_lua_float(self):
pval = 10.1
lval = MockRedisScript._python_to_lua(pval)
lval_expected = self.lua.eval("10.1")
eq_("number", self.lua_globals.type(lval))
ok_(MockRedisScript._lua_to_python(self.lua_compare_val(lval_expected, lval)))
开发者ID:RedisLabs,项目名称:mockredis,代码行数:6,代码来源:test_script.py
示例8: test_python_to_lua_list
def test_python_to_lua_list(self):
pval = ["abc", "xyz"]
lval = MockRedisScript._python_to_lua(pval)
lval_expected = self.lua.eval('{"abc", "xyz"}')
self.lua_assert_equal_list(lval_expected, lval)
开发者ID:RedisLabs,项目名称:mockredis,代码行数:5,代码来源:test_script.py
示例9: test_python_to_lua_long
def test_python_to_lua_long(self):
pval = long(10)
lval = MockRedisScript._python_to_lua(pval)
lval_expected = self.lua.eval('10')
eq_("number", self.lua_globals.type(lval))
ok_(MockRedisScript._lua_to_python(self.lua_compare_val(lval_expected, lval)))
开发者ID:asherf,项目名称:mockredis,代码行数:6,代码来源:test_script.py
示例10: test_python_to_lua_boolean
def test_python_to_lua_boolean(self):
pval = True
lval = MockredisScript._python_to_lua(pval)
self.assertEqual("boolean", self.lua_globals.type(lval))
self.assertTrue(MockredisScript._lua_to_python(lval))
开发者ID:aim110,项目名称:mockredis,代码行数:5,代码来源:test_script.py
示例11: test_python_to_lua_float
def test_python_to_lua_float(self):
pval = 10.1
lval = MockredisScript._python_to_lua(pval)
lval_expected = self.lua.eval('10.1')
self.assertEqual("number", self.lua_globals.type(lval))
self.assertTrue(MockredisScript._lua_to_python(self.lua_compare_val(lval_expected, lval)))
开发者ID:aim110,项目名称:mockredis,代码行数:6,代码来源:test_script.py
示例12: test_lua_to_python_bool
def test_lua_to_python_bool(self):
lval = self.lua.eval('true')
pval = MockredisScript._lua_to_python(lval)
self.assertIsInstance(pval, bool)
self.assertEqual(True, pval)
开发者ID:aim110,项目名称:mockredis,代码行数:5,代码来源:test_script.py
示例13: test_lua_to_python_string
def test_lua_to_python_string(self):
lval = self.lua.eval('"somestring"')
pval = MockredisScript._lua_to_python(lval)
self.assertIsInstance(pval, str)
self.assertEqual("somestring", pval)
开发者ID:aim110,项目名称:mockredis,代码行数:5,代码来源:test_script.py
示例14: test_lua_to_python_flota
def test_lua_to_python_flota(self):
lval = self.lua.eval('22.2')
pval = MockredisScript._lua_to_python(lval)
self.assertIsInstance(pval, float)
self.assertEqual(22.2, pval)
开发者ID:aim110,项目名称:mockredis,代码行数:5,代码来源:test_script.py
示例15: test_lua_to_python_long
def test_lua_to_python_long(self):
lval = self.lua.eval('22')
pval = MockredisScript._lua_to_python(lval)
self.assertIsInstance(pval, long)
self.assertEqual(22, pval)
开发者ID:aim110,项目名称:mockredis,代码行数:5,代码来源:test_script.py
示例16: setup
def setup(self):
self.redis = MockRedis(load_lua_dependencies=False)
self.LPOP_SCRIPT_SHA = sha1(LPOP_SCRIPT.encode("utf-8")).hexdigest()
try:
lua, lua_globals = MockRedisScript._import_lua(load_dependencies=False)
except RuntimeError:
raise SkipTest("mockredispy was not installed with lua support")
self.lua = lua
self.lua_globals = lua_globals
assert_equal_list = """
function compare_list(list1, list2)
if #list1 ~= #list2 then
return false
end
for i, item1 in ipairs(list1) do
if item1 ~= list2[i] then
return false
end
end
return true
end
function assert_equal_list(list1, list2)
assert(compare_list(list1, list2))
end
return assert_equal_list
"""
self.lua_assert_equal_list = self.lua.execute(assert_equal_list)
assert_equal_list_with_pairs = """
function pair_exists(list1, key, value)
i = 1
for i, item1 in ipairs(list1) do
if i%2 == 1 then
if (list1[i] == key) and (list1[i + 1] == value) then
return true
end
end
end
return false
end
function compare_list_with_pairs(list1, list2)
if #list1 ~= #list2 or #list1 % 2 == 1 then
return false
end
for i = 1, #list1, 2 do
if not pair_exists(list2, list1[i], list1[i + 1]) then
return false
end
end
return true
end
function assert_equal_list_with_pairs(list1, list2)
assert(compare_list_with_pairs(list1, list2))
end
return assert_equal_list_with_pairs
"""
self.lua_assert_equal_list_with_pairs = self.lua.execute(assert_equal_list_with_pairs)
compare_val = """
function compare_val(var1, var2)
return var1 == var2
end
return compare_val
"""
self.lua_compare_val = self.lua.execute(compare_val)
开发者ID:RedisLabs,项目名称:mockredis,代码行数:71,代码来源:test_script.py
示例17: test_python_to_lua_string
def test_python_to_lua_string(self):
pval = "somestring"
lval = MockRedisScript._python_to_lua(pval)
lval_expected = self.lua.eval('"somestring"')
eq_("string", self.lua_globals.type(lval))
eq_(lval_expected, lval)
开发者ID:RedisLabs,项目名称:mockredis,代码行数:6,代码来源:test_script.py
示例18: test_lua_to_python_none
def test_lua_to_python_none(self):
lval = self.lua.eval("")
pval = MockRedisScript._lua_to_python(lval)
ok_(pval is None)
开发者ID:RedisLabs,项目名称:mockredis,代码行数:4,代码来源:test_script.py
示例19: test_python_to_lua_dict
def test_python_to_lua_dict(self):
pval = {"k1": "v1", "k2": "v2"}
lval = MockRedisScript._python_to_lua(pval)
lval_expected = self.lua.eval('{"k1", "v1", "k2", "v2"}')
self.lua_assert_equal_list_with_pairs(lval_expected, lval)
开发者ID:RedisLabs,项目名称:mockredis,代码行数:5,代码来源:test_script.py
示例20: test_lua_to_python_list
def test_lua_to_python_list(self):
lval = self.lua.eval('{"val1", "val2"}')
pval = MockRedisScript._lua_to_python(lval)
ok_(isinstance(pval, list))
eq_(["val1", "val2"], pval)
开发者ID:RedisLabs,项目名称:mockredis,代码行数:5,代码来源:test_script.py
注:本文中的mockredis.script.Script类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论