--- /dev/null
+# Copyright (C) 2024 The Meme Factory, Inc. http://www.karlpinc.com/
+
+# This file is part of PGWUI_SQL.
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU Affero General Public License
+# as published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/>.
+#
+
+import io
+
+
+def normalize_newlines(sval):
+ '''Apply the Python io module's univeral newline transalation to a string
+ '''
+ return io.StringIO(sval, newline=None).getvalue()
--- /dev/null
+# Copyright (C) 2024 The Meme Factory, Inc. http://www.karlpinc.com/
+
+# This file is part of PGWUI_SQL.
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU Affero General Public License
+# as published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/>.
+#
+
+# Karl O. Pinc <kop@karlpinc.com>
+
+import pgwui_sql.lib as lib
+import pytest
+
+
+# Activiate the PGWUI pytest plugin
+pytest_plugins = ("pgwui",)
+
+
+# normalize_newlines()
+@pytest.mark.unittest
+@pytest.mark.parametrize(
+ 'val,expected',
+ [('this has no newlines', 'this has no newlines'),
+ ('this\nhas\n newlines\n', 'this\nhas\n newlines\n'),
+ ('this\r\nhas\r\n newlines\r\n', 'this\nhas\n newlines\n'),
+ ('this\rhas\r newlines\r', 'this\nhas\n newlines\n')],
+ ids=('no_newlines', 'newlines', 'crlf', 'cr'))
+def test_normalize_newlines(val, expected):
+ '''The expected normalization happens
+ '''
+ result = lib.normalize_newlines(val)
+ assert result == expected