@@ -11,10 +11,12 @@ def test_format_messy_config():
11
11
output = crossplane .format (config )
12
12
assert output == '\n ' .join ([
13
13
'user nobody;' ,
14
+ r'# hello\n\\n\\\n worlddd \#\\#\\\# dfsf\n \\n \\\n ' ,
14
15
'events {' ,
15
16
' worker_connections 2048;' ,
16
17
'}' ,
17
- 'http {' ,
18
+ 'http { #forteen' ,
19
+ ' # this is a comment' ,
18
20
' access_log off;' ,
19
21
' default_type text/plain;' ,
20
22
' error_log off;' ,
@@ -33,7 +35,7 @@ def test_format_messy_config():
33
35
' location /bar {' ,
34
36
' }' ,
35
37
' location /\{\;\}\ #\ ab {' ,
36
- ' }' ,
38
+ ' } # hello ' ,
37
39
' if ($request_method = P\{O\)\###\;ST) {' ,
38
40
' }' ,
39
41
' location /status.html {' ,
@@ -75,3 +77,25 @@ def test_format_args_not_analyzed():
75
77
'http {' ,
76
78
'}'
77
79
])
80
+
81
+
82
+ def test_format_with_comments ():
83
+ dirname = os .path .join (here , 'configs' , 'with-comments' )
84
+ config = os .path .join (dirname , 'nginx.conf' )
85
+ output = crossplane .format (config )
86
+ assert output == '\n ' .join ([
87
+ 'events {' ,
88
+ ' worker_connections 1024;' ,
89
+ '}' ,
90
+ '#comment' ,
91
+ 'http {' ,
92
+ ' server {' ,
93
+ ' listen 127.0.0.1:8080; #listen' ,
94
+ ' server_name default_server;' ,
95
+ ' location / { ## this is brace' ,
96
+ ' # location /' ,
97
+ " return 200 'foo bar baz';" ,
98
+ ' }' ,
99
+ ' }' ,
100
+ '}'
101
+ ])
0 commit comments