Mercurial > p > roundup > code
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 7584:a5629f6e7ec2 | 7585:227aca44fea5 |
|---|---|
| 48 output = out.getvalue().strip() | 48 output = out.getvalue().strip() |
| 49 print(output) | 49 print(output) |
| 50 | 50 |
| 51 # verify that db was set properly by reading config | 51 # verify that db was set properly by reading config |
| 52 with open(self.home + "/config.ini", "r") as f: | 52 with open(self.home + "/config.ini", "r") as f: |
| 53 config_lines = f.readlines() | 53 config_lines = f.read().replace("\r\n", "\n") |
| 54 | |
| 55 try: | |
| 56 # handle text files with \r\n line endings | |
| 57 config_lines.index("\r") | |
| 58 config_lines = config_lines.replace("\r\n", "\n") | |
| 59 except ValueError: | |
| 60 pass | |
| 54 | 61 |
| 55 self.assertIn("backend = %s\n"%db, config_lines) | 62 self.assertIn("backend = %s\n"%db, config_lines) |
| 56 | 63 |
| 57 # dummy up the return of get_server so the serve_forever method | 64 # dummy up the return of get_server so the serve_forever method |
| 58 # raises keyboard interrupt exiting the server so the test exits. | 65 # raises keyboard interrupt exiting the server so the test exits. |
| 86 def testDemoJinja(self): | 93 def testDemoJinja(self): |
| 87 self.run_install_demo('jinja2', db="anydbm") | 94 self.run_install_demo('jinja2', db="anydbm") |
| 88 | 95 |
| 89 # verify that template was set to jinja2 by reading config | 96 # verify that template was set to jinja2 by reading config |
| 90 with open(self.home + "/config.ini", "r") as f: | 97 with open(self.home + "/config.ini", "r") as f: |
| 91 config_lines = f.readlines() | 98 config_lines = f.read() |
| 99 | |
| 100 try: | |
| 101 # handle text files with \r\n line endings | |
| 102 config_lines.index("\r") | |
| 103 config_lines = config_lines.replace("\r\n", "\n") | |
| 104 except ValueError: | |
| 105 pass | |
| 92 | 106 |
| 93 self.assertIn("template_engine = jinja2\n", config_lines) | 107 self.assertIn("template_engine = jinja2\n", config_lines) |
| 94 | 108 |
