Skip to content

Commit d9d1a63

Browse files
committed
Add test for missing semi colon
1 parent 8c10798 commit d9d1a63

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"""
88

99
# flake8: noqa
10+
import pytest
1011

1112
import nginx
1213
import unittest
@@ -177,6 +178,22 @@
177178
}
178179
"""
179180

181+
TESTBLOCK_CASE_11 = """
182+
server{
183+
listen 80;
184+
#OPEN-PORT-443
185+
listen 443 ssl;
186+
server_name www.xxx.com;
187+
root /wwww/wwww;
188+
189+
location ~ .*\.(js|css)?$ {
190+
expires 12h;
191+
error_log off;
192+
access_log /dev/null # MISSING SEMICOLON
193+
}
194+
}
195+
"""
196+
180197

181198
class TestPythonNginx(unittest.TestCase):
182199
def test_basic_load(self):
@@ -290,5 +307,11 @@ def test_types_block(self):
290307
data_type = inp_data.filter("Types")[0].filter("Key")[0]
291308
self.assertEqual(data_type.value, "cea")
292309

310+
def test_missing_semi_colon(self):
311+
with pytest.raises(nginx.ParseError) as e:
312+
nginx.loads(TESTBLOCK_CASE_11)
313+
self.assertEqual(str(e.value), "Config syntax, missing ';' at index: 189")
314+
315+
293316
if __name__ == '__main__':
294317
unittest.main()

0 commit comments

Comments
 (0)