Mercurial > p > roundup > code
diff test/test_demo.py @ 7585:227aca44fea5
test: fix failure under cygwin python caused by line endings
reading config.ini files under cygwin python results in \r\n
terminated lines which do not compare properly with the success
conditions.
replace \r\n with \n when required.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 24 Jul 2023 21:16:41 -0400 |
| parents | 4cfaddc2d53e |
| children | 859c57bc8d91 |
line wrap: on
line diff
--- a/test/test_demo.py Mon Jul 24 18:07:11 2023 -0400 +++ b/test/test_demo.py Mon Jul 24 21:16:41 2023 -0400 @@ -50,7 +50,14 @@ # verify that db was set properly by reading config with open(self.home + "/config.ini", "r") as f: - config_lines = f.readlines() + config_lines = f.read().replace("\r\n", "\n") + + try: + # handle text files with \r\n line endings + config_lines.index("\r") + config_lines = config_lines.replace("\r\n", "\n") + except ValueError: + pass self.assertIn("backend = %s\n"%db, config_lines) @@ -88,7 +95,14 @@ # verify that template was set to jinja2 by reading config with open(self.home + "/config.ini", "r") as f: - config_lines = f.readlines() + config_lines = f.read() + + try: + # handle text files with \r\n line endings + config_lines.index("\r") + config_lines = config_lines.replace("\r\n", "\n") + except ValueError: + pass self.assertIn("template_engine = jinja2\n", config_lines)
