From 70a0198ecb1e7784101163d4681a109e7f75350d Mon Sep 17 00:00:00 2001 From: yongfu Date: Tue, 25 Sep 2018 20:56:37 +0800 Subject: [PATCH] add test for multi_semicolon and rewrite reg --- test_nginxfmt.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test_nginxfmt.py b/test_nginxfmt.py index 9018cd4..17c662d 100644 --- a/test_nginxfmt.py +++ b/test_nginxfmt.py @@ -36,6 +36,12 @@ class TestFormatter(unittest.TestCase): self.assertEqual(["{", "ala", "# ma {{", "kota", "}", "to", "}", "# }"], clean_lines(("{", "ala ", "# ma {{", " kota ", "}", " to} ", "# }"))) + + self.assertEqual(["{", "ala", "# ma {{", "rewrite /([\d]{2}) /up/$1.html last;", "}", "to", "}"], + clean_lines(("{", "ala ", "# ma {{", " rewrite /([\d]{2}) /up/$1.html last; ", "}", " to", "}"))) + + self.assertEqual(["{", "ala", "# ma {{", "aa last;", "bb to;", "}"], + clean_lines(("{", "ala ", "# ma {{", " aa last; bb to; ", "}"))) self.assertEqual(["location ~ /\.ht", "{"], clean_lines(["location ~ /\.ht {", ])) @@ -178,6 +184,16 @@ class TestFormatter(unittest.TestCase): '}\n' + '# in my line\n') + def test_multi_semicolon(self): + self._check_formatting('location /a { \n' + + 'allow 127.0.0.1; allow 10.0.0.0/8; deny all; \n' + + '}\n', + 'location /a {\n' + + ' allow 127.0.0.1;\n' + + ' allow 10.0.0.0/8;\n' + + ' deny all;\n' + + '}\n') + def test_loading_utf8_file(self): tmp_file = tempfile.mkstemp('utf-8')[1] shutil.copy('test-files/umlaut-utf8.conf', tmp_file)