MCPcopy
hub / github.com/scrapinghub/splash / test_sparse_list

Method test_sparse_list

splash/tests/test_lua_utils.py:124–142  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

122 self.assertSurvivesConversion([None, None, None, 2], encoding='utf8')
123
124 def test_sparse_list(self):
125 func1 = self.lua.eval("""
126 function (arr)
127 arr[5] = "foo"
128 return arr
129 end
130 """)
131 func2 = self.lua.eval("""
132 function (arr)
133 arr[100000] = "foo"
134 return arr
135 end
136 """)
137 arr = python2lua(self.lua, [1, 2])
138 arr1 = lua2python(self.lua, func1(arr))
139 self.assertEqual(arr1, [1, 2, None, None, "foo"])
140
141 with pytest.raises(ValueError):
142 arr2 = lua2python(self.lua, func2(arr))
143
144 def test_list_like_tables(self):
145 # List-like tables are still returned as dicts;

Callers

nothing calls this directly

Calls 3

python2luaFunction · 0.90
lua2pythonFunction · 0.90
evalMethod · 0.80

Tested by

no test coverage detected