diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2021-09-07 12:27:28 +0200 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2021-09-10 08:49:09 +0200 |
| commit | 8238a9e450ed1524e40cb3a8b0b3c00606903aeb (patch) | |
| tree | 76757406d040030ad733b946eb09fb06ed11e5fc /tests/test_format.py | |
| parent | e66046785b816e5c2d22f101f36faefd19c4a771 (diff) | |
| download | sqlparse-8238a9e450ed1524e40cb3a8b0b3c00606903aeb.tar.gz | |
Optimize regular expression for identifying line breaks in comments.
Diffstat (limited to 'tests/test_format.py')
| -rw-r--r-- | tests/test_format.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_format.py b/tests/test_format.py index 7117d9d..70bb805 100644 --- a/tests/test_format.py +++ b/tests/test_format.py @@ -84,6 +84,23 @@ class TestFormat: res = sqlparse.format(sql, strip_comments=True) assert res == 'select (select 2)' + def test_strip_comments_preserves_linebreak(self): + sql = 'select * -- a comment\r\nfrom foo' + res = sqlparse.format(sql, strip_comments=True) + assert res == 'select *\nfrom foo' + sql = 'select * -- a comment\nfrom foo' + res = sqlparse.format(sql, strip_comments=True) + assert res == 'select *\nfrom foo' + sql = 'select * -- a comment\rfrom foo' + res = sqlparse.format(sql, strip_comments=True) + assert res == 'select *\nfrom foo' + sql = 'select * -- a comment\r\n\r\nfrom foo' + res = sqlparse.format(sql, strip_comments=True) + assert res == 'select *\n\nfrom foo' + sql = 'select * -- a comment\n\nfrom foo' + res = sqlparse.format(sql, strip_comments=True) + assert res == 'select *\n\nfrom foo' + def test_strip_ws(self): f = lambda sql: sqlparse.format(sql, strip_whitespace=True) s = 'select\n* from foo\n\twhere ( 1 = 2 )\n' |
