From 3c319408d0de2d2de0c19b24e1a41c0a0e4a823b Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Mon, 22 Mar 2021 15:07:18 +0100 Subject: libucl: import latest snapshot from 2021-03-14 --- python/tests/test_example.py | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 python/tests/test_example.py (limited to 'python/tests/test_example.py') diff --git a/python/tests/test_example.py b/python/tests/test_example.py new file mode 100644 index 000000000000..f0785531f4e2 --- /dev/null +++ b/python/tests/test_example.py @@ -0,0 +1,59 @@ +from .compat import unittest +import json +import ucl + +_ucl_inp = ''' +param = value; +section { + param = value; + param1 = value1; + flag = true; + number = 10k; + time = 0.2s; + string = "something"; + subsection { + host = { + host = "hostname"; + port = 900; + } + host = { + host = "hostname"; + port = 901; + } + } +} +''' + +_json_res = { + 'param': 'value', + 'section': { + 'param': 'value', + 'param1': 'value1', + 'flag': True, + 'number': 10000, + 'time': '0.2s', + 'string': 'something', + 'subsection': { + 'host': [ + { + 'host': 'hostname', + 'port': 900, + }, + { + 'host': 'hostname', + 'port': 901, + } + ] + } + } +} + +class TestExample(unittest.TestCase): + def test_example(self): + # load in sample UCL + u = ucl.load(_ucl_inp) + + # Output and read back the JSON + uj = json.loads(json.dumps(u)) + + self.assertEqual(uj, _json_res) -- cgit v1.3