Skip to content

Commit

Permalink
Merge branch 'temp' into nested-dict
Browse files Browse the repository at this point in the history
  • Loading branch information
synodriver committed Feb 20, 2024
2 parents 7a69ee8 + b241664 commit 0e07ff5
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 4 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@ build
dist
MANIFEST
*.pyc
*.pyo
*.pyd
*.dll
*.egg-info
*.so
*.c
*.patch
wheel*/
*.orig
*~
*wheel*/
venv*
.eggs/
lupa/version.py
lupa/lua*.pyx
TEST/

# Vim swapfiles
*.swp
Expand Down
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Lupa change log
* The bundled Lua 5.1 was updated to 5.1.5 and Lua 5.2 to 5.2.4.
(patch by xxyzz)

* Built with Cython 3.0.6 for improved support of Python 3.12.
* Built with Cython 3.0.8 for improved support of Python 3.12.


2.0 (2023-04-03)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ sdist dist/lupa-$(VERSION).tar.gz:
${PYTHON} setup.py sdist

test: local
PYTHONPATH=. $(PYTHON) -m unittest lupa.tests.test
PYTHONPATH=. $(PYTHON) -m unittest -v lupa.tests.test

clean:
rm -fr build lupa/_lupa*.so lupa/lua*.pyx lupa/*.c
Expand Down
8 changes: 8 additions & 0 deletions lupa/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ class LupaTestCase(unittest.TestCase):
"""
lupa = lupa

if sys.version_info < (3, 4):
from contextlib import contextmanager

@contextmanager
def subTest(self, message=None, **parameters):
"""Dummy implementation"""
yield


def find_lua_modules():
modules = [lupa]
Expand Down
17 changes: 17 additions & 0 deletions lupa/tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,23 @@ def test_table_from_self_ref_obj(self):
self.assertLuaResult("type(data['key']['key']['key']['key'])", 'table')
self.assertLuaResult("type(data['key']['key']['key']['key']['list'])", 'table')

def test_table_from_nested_datastructures(self):
from itertools import count
def make_ds(*children):
yield list(children)
yield dict(zip(count(), children))
yield {chr(ord('A') + i): child for i, child in enumerate(children)}

elements = [1, 2, 'x', 'y']
for ds1 in make_ds(*elements):
for ds2 in make_ds(ds1):
for ds3 in make_ds(ds1, elements, ds2):
for ds in make_ds(ds1, ds2, ds3):
with self.subTest(ds=ds):
table = self.lua.table_from(ds)
# we don't translate transitively, so apply arbitrary test operation
self.assertTrue(list(table))

# FIXME: it segfaults
# def test_table_from_generator_calling_lua_functions(self):
# func = self.lua.eval("function (obj) return obj end")
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Cython>=3.0.6
Cython>=3.0.8
setuptools

0 comments on commit 0e07ff5

Please sign in to comment.