aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_utils.py
diff options
context:
space:
mode:
authorChillingPepper <90042155+ChillingPepper@users.noreply.github.com>2022-12-30 07:38:38 +0100
committerGitHub <noreply@github.com>2022-12-30 12:08:38 +0530
commitd5f043d127cac1e8ec8a6eacde04ad1133600a16 (patch)
tree9501d4c0aa7118f90864e39484aa387569ff9ecc /test/test_utils.py
parentfe74d5b592438c669f5717b34504f27c34ca9904 (diff)
downloadhypervideo-pre-d5f043d127cac1e8ec8a6eacde04ad1133600a16.tar.lz
hypervideo-pre-d5f043d127cac1e8ec8a6eacde04ad1133600a16.tar.xz
hypervideo-pre-d5f043d127cac1e8ec8a6eacde04ad1133600a16.zip
[utils] js_to_json: Fix bug in f55523c (#5771)
Authored by: ChillingPepper, pukkandan
Diffstat (limited to 'test/test_utils.py')
-rw-r--r--test/test_utils.py79
1 files changed, 79 insertions, 0 deletions
diff --git a/test/test_utils.py b/test/test_utils.py
index 49ab3796b..82ae77ea2 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -954,6 +954,85 @@ class TestUtil(unittest.TestCase):
)
self.assertEqual(escape_url('http://vimeo.com/56015672#at=0'), 'http://vimeo.com/56015672#at=0')
+ def test_js_to_json_vars_strings(self):
+ self.assertDictEqual(
+ json.loads(js_to_json(
+ '''{
+ 'null': a,
+ 'nullStr': b,
+ 'true': c,
+ 'trueStr': d,
+ 'false': e,
+ 'falseStr': f,
+ 'unresolvedVar': g,
+ }''',
+ {
+ 'a': 'null',
+ 'b': '"null"',
+ 'c': 'true',
+ 'd': '"true"',
+ 'e': 'false',
+ 'f': '"false"',
+ 'g': 'var',
+ }
+ )),
+ {
+ 'null': None,
+ 'nullStr': 'null',
+ 'true': True,
+ 'trueStr': 'true',
+ 'false': False,
+ 'falseStr': 'false',
+ 'unresolvedVar': 'var'
+ }
+ )
+
+ self.assertDictEqual(
+ json.loads(js_to_json(
+ '''{
+ 'int': a,
+ 'intStr': b,
+ 'float': c,
+ 'floatStr': d,
+ }''',
+ {
+ 'a': '123',
+ 'b': '"123"',
+ 'c': '1.23',
+ 'd': '"1.23"',
+ }
+ )),
+ {
+ 'int': 123,
+ 'intStr': '123',
+ 'float': 1.23,
+ 'floatStr': '1.23',
+ }
+ )
+
+ self.assertDictEqual(
+ json.loads(js_to_json(
+ '''{
+ 'object': a,
+ 'objectStr': b,
+ 'array': c,
+ 'arrayStr': d,
+ }''',
+ {
+ 'a': '{}',
+ 'b': '"{}"',
+ 'c': '[]',
+ 'd': '"[]"',
+ }
+ )),
+ {
+ 'object': {},
+ 'objectStr': '{}',
+ 'array': [],
+ 'arrayStr': '[]',
+ }
+ )
+
def test_js_to_json_realworld(self):
inp = '''{
'clip':{'provider':'pseudo'}