From 2f0a2a43bbfcb2aef1569b48277933264ec25feb Mon Sep 17 00:00:00 2001 From: Yegor Yefremov Date: Mon, 12 Dec 2022 10:50:50 +0100 Subject: [PATCH] support/testing: add test for python-munch Signed-off-by: Yegor Yefremov Signed-off-by: Thomas Petazzoni --- DEVELOPERS | 2 ++ .../tests/package/sample_python_munch.py | 20 +++++++++++++++++++ .../tests/package/test_python_munch.py | 12 +++++++++++ 3 files changed, 34 insertions(+) create mode 100644 support/testing/tests/package/sample_python_munch.py create mode 100644 support/testing/tests/package/test_python_munch.py diff --git a/DEVELOPERS b/DEVELOPERS index 0eea9c33d9..3217823b6f 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -3133,10 +3133,12 @@ F: package/x11r7/xapp_xinput-calibrator/ F: package/zlog/ F: support/testing/tests/package/sample_python_dicttoxml2.py F: support/testing/tests/package/sample_python_dtschema.py +F: support/testing/tests/package/sample_python_munch.py F: support/testing/tests/package/test_libftdi1.py F: support/testing/tests/package/test_python_can.py F: support/testing/tests/package/test_python_dicttoxml2.py F: support/testing/tests/package/test_python_dtschema.py +F: support/testing/tests/package/test_python_munch.py F: utils/scanpypi N: Yunhao Tian diff --git a/support/testing/tests/package/sample_python_munch.py b/support/testing/tests/package/sample_python_munch.py new file mode 100644 index 0000000000..b45bec7b7e --- /dev/null +++ b/support/testing/tests/package/sample_python_munch.py @@ -0,0 +1,20 @@ +from munch import Munch + +b = Munch() +b.hello = 'world' +assert b.hello == 'world' +b['hello'] += "!" +assert b.hello == 'world!' +b.foo = Munch(lol=True) +assert b.foo.lol is True +assert b.foo is b['foo'] + +assert sorted(b.keys()) == ['foo', 'hello'] + +b.update({'ponies': 'are pretty!'}, hello=42) +assert b == Munch({'ponies': 'are pretty!', 'foo': Munch({'lol': True}), 'hello': 42}) + +assert sorted([(k, b[k]) for k in b]) == [('foo', Munch({'lol': True})), ('hello', 42), ('ponies', 'are pretty!')] + +format_munch = Munch(knights='lolcats', ni='can haz') +assert "The {knights} who say {ni}!".format(**format_munch) == 'The lolcats who say can haz!' diff --git a/support/testing/tests/package/test_python_munch.py b/support/testing/tests/package/test_python_munch.py new file mode 100644 index 0000000000..6853bbaac7 --- /dev/null +++ b/support/testing/tests/package/test_python_munch.py @@ -0,0 +1,12 @@ +from tests.package.test_python import TestPythonPackageBase + + +class TestPythonPy3Munch(TestPythonPackageBase): + __test__ = True + config = TestPythonPackageBase.config + \ + """ + BR2_PACKAGE_PYTHON3=y + BR2_PACKAGE_PYTHON_MUNCH=y + """ + sample_scripts = ["tests/package/sample_python_munch.py"] + timeout = 40