diff mbox series

[2/4] support/testing: add new python-ruamel-yaml runtime test

Message ID 20240207170959.2672846-2-buildroot@bubu1.eu
State Accepted
Headers show
Series [1/4] package/python-ruamel-yaml: fix comment in hash file | expand

Commit Message

Marcus Hoffmann Feb. 7, 2024, 5:09 p.m. UTC
Signed-off-by: Marcus Hoffmann <buildroot@bubu1.eu>
---
 .../package/sample_python_ruamel_yaml.py      | 27 +++++++++++++++++++
 .../tests/package/test_python_ruamel_yaml.py  | 12 +++++++++
 2 files changed, 39 insertions(+)
 create mode 100644 support/testing/tests/package/sample_python_ruamel_yaml.py
 create mode 100644 support/testing/tests/package/test_python_ruamel_yaml.py

Comments

Thomas Petazzoni July 12, 2024, 1:06 p.m. UTC | #1
On Wed,  7 Feb 2024 18:09:54 +0100
Marcus Hoffmann via buildroot <buildroot@buildroot.org> wrote:

> Signed-off-by: Marcus Hoffmann <buildroot@bubu1.eu>
> ---
>  .../package/sample_python_ruamel_yaml.py      | 27 +++++++++++++++++++
>  .../tests/package/test_python_ruamel_yaml.py  | 12 +++++++++
>  2 files changed, 39 insertions(+)
>  create mode 100644 support/testing/tests/package/sample_python_ruamel_yaml.py
>  create mode 100644 support/testing/tests/package/test_python_ruamel_yaml.py

You had forgotten to add an entry in the DEVELOPERS file for those two
new files, so I did that and applied. Thanks a lot!

Thomas
Peter Korsgaard July 31, 2024, 3:38 p.m. UTC | #2
>>>>> "Marcus" == Marcus Hoffmann via buildroot <buildroot@buildroot.org> writes:

 > Signed-off-by: Marcus Hoffmann <buildroot@bubu1.eu>

Committed to 2024.02.x and 2024.05.x, thanks.
diff mbox series

Patch

diff --git a/support/testing/tests/package/sample_python_ruamel_yaml.py b/support/testing/tests/package/sample_python_ruamel_yaml.py
new file mode 100644
index 0000000000..5b3a079471
--- /dev/null
+++ b/support/testing/tests/package/sample_python_ruamel_yaml.py
@@ -0,0 +1,27 @@ 
+from ruamel.yaml import YAML
+
+yaml_text = """
+Rootkey:
+  - ListEntry
+AnotherRootKey: some-string
+
+ListRoot:
+  - float-value: '1.0'
+    int-value: 10234
+    NestedList:
+      - 1
+      - 2
+
+  - another-float: '1.1'
+    another-int: 1111
+
+OneMoreRootKey: 9.99
+"""
+
+# Tests the pure python based implementation
+yaml = YAML(typ='safe', pure=True)
+
+parsed = yaml.load(yaml_text)
+
+assert parsed['OneMoreRootKey'] == 9.99
+assert parsed['ListRoot'][1]['another-int'] == 1111
diff --git a/support/testing/tests/package/test_python_ruamel_yaml.py b/support/testing/tests/package/test_python_ruamel_yaml.py
new file mode 100644
index 0000000000..15062b4455
--- /dev/null
+++ b/support/testing/tests/package/test_python_ruamel_yaml.py
@@ -0,0 +1,12 @@ 
+from tests.package.test_python import TestPythonPackageBase
+
+
+class TestPythonPy3RuamelYaml(TestPythonPackageBase):
+    __test__ = True
+    config = TestPythonPackageBase.config + \
+        """
+        BR2_PACKAGE_PYTHON3=y
+        BR2_PACKAGE_PYTHON_RUAMEL_YAML=y
+        """
+    sample_scripts = ["tests/package/sample_python_ruamel_yaml.py"]
+    timeout = 40