diff options
author | Andrei Belov <defan@nginx.com> | 2020-04-16 18:27:26 +0300 |
---|---|---|
committer | Andrei Belov <defan@nginx.com> | 2020-04-16 18:27:26 +0300 |
commit | 74f32d26b91f49d3392605e81c1597b375890b60 (patch) | |
tree | adfc67dfc86461441bde65512f745ce27bd6ea28 /test/test_configuration.py | |
parent | 2ff9df10ef1df43c935c870175e52473dad2c21a (diff) | |
parent | 9877087756144d3bdf343d0d4e91e1efbcc62c93 (diff) | |
download | unit-74f32d26b91f49d3392605e81c1597b375890b60.tar.gz unit-74f32d26b91f49d3392605e81c1597b375890b60.tar.bz2 |
Merged with the default branch.1.17.0-1
Diffstat (limited to '')
-rw-r--r-- | test/test_configuration.py | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/test/test_configuration.py b/test/test_configuration.py index 186e037d..daba874b 100644 --- a/test/test_configuration.py +++ b/test/test_configuration.py @@ -83,6 +83,86 @@ class TestConfiguration(TestControl): 'unicode number', ) + def test_json_utf8_bom(self): + self.assertIn( + 'success', + self.conf( + b"""\xEF\xBB\xBF + { + "app": { + "type": "python", + "processes": {"spare": 0}, + "path": "/app", + "module": "wsgi" + } + } + """, + 'applications', + ), + 'UTF-8 BOM', + ) + + def test_json_comment_single_line(self): + self.assertIn( + 'success', + self.conf( + b""" + // this is bridge + { + "//app": { + "type": "python", // end line + "processes": {"spare": 0}, + // inside of block + "path": "/app", + "module": "wsgi" + } + // double // + } + // end of json \xEF\t + """, + 'applications', + ), + 'single line comments', + ) + + def test_json_comment_multi_line(self): + self.assertIn( + 'success', + self.conf( + b""" + /* this is bridge */ + { + "/*app": { + /** + * multiple lines + **/ + "type": "python", + "processes": /* inline */ {"spare": 0}, + "path": "/app", + "module": "wsgi" + /* + // end of block */ + } + /* blah * / blah /* blah */ + } + /* end of json \xEF\t\b */ + """, + 'applications', + ), + 'multi line comments', + ) + + def test_json_comment_invalid(self): + self.assertIn('error', self.conf(b'/{}', 'applications'), 'slash') + self.assertIn('error', self.conf(b'//{}', 'applications'), 'comment') + self.assertIn('error', self.conf(b'{} /', 'applications'), 'slash end') + self.assertIn( + 'error', self.conf(b'/*{}', 'applications'), 'slash star' + ) + self.assertIn( + 'error', self.conf(b'{} /*', 'applications'), 'slash star end' + ) + def test_applications_open_brace(self): self.assertIn('error', self.conf('{', 'applications'), 'open brace') |