Explorar o código

support/testing: add test for python-dicttoxml2

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Yegor Yefremov %!s(int64=2) %!d(string=hai) anos
pai
achega
b54e0dde30

+ 2 - 0
DEVELOPERS

@@ -3117,9 +3117,11 @@ F:	package/wpa_supplicant/
 F:	package/x11r7/xapp_xconsole/
 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/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:	utils/scanpypi
 

+ 11 - 0
support/testing/tests/package/sample_python_dicttoxml2.py

@@ -0,0 +1,11 @@
+from dicttoxml2 import dicttoxml
+
+payload: dict = {'mylist': ['foo', 'bar', 'baz'], 'mydict': {'foo': 'bar', 'baz': 1}, 'ok': True}
+
+expected: bytes = b'<?xml version="1.0" encoding="UTF-8" ?><root><mylist type="list"><item type="str">' \
+                  b'<![CDATA[foo]]></item><item type="str"><![CDATA[bar]]></item><item type="str"><![CDATA[baz]]>' \
+                  b'</item></mylist><mydict type="dict"><foo type="str"><![CDATA[bar]]></foo><baz type="int">' \
+                  b'<![CDATA[1]]></baz></mydict><ok type="bool"><![CDATA[True]]>' \
+                  b'</ok></root>'
+
+assert dicttoxml(payload, cdata=True) == expected

+ 12 - 0
support/testing/tests/package/test_python_dicttoxml2.py

@@ -0,0 +1,12 @@
+from tests.package.test_python import TestPythonPackageBase
+
+
+class TestPythonPy3Dicttoxml2(TestPythonPackageBase):
+    __test__ = True
+    config = TestPythonPackageBase.config + \
+        """
+        BR2_PACKAGE_PYTHON3=y
+        BR2_PACKAGE_PYTHON_DICTTOXML2=y
+        """
+    sample_scripts = ["tests/package/sample_python_dicttoxml2.py"]
+    timeout = 40