Mercurial > p > roundup > code
comparison test/test_demo.py @ 7586:859c57bc8d91
test: limit search for \r to first 100 bytes.
Don't scan entire file. just look at 100 bytes which should include
all of the first line.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 24 Jul 2023 21:24:07 -0400 |
| parents | 227aca44fea5 |
| children | 5b1163dca9e1 |
comparison
equal
deleted
inserted
replaced
| 7585:227aca44fea5 | 7586:859c57bc8d91 |
|---|---|
| 52 with open(self.home + "/config.ini", "r") as f: | 52 with open(self.home + "/config.ini", "r") as f: |
| 53 config_lines = f.read().replace("\r\n", "\n") | 53 config_lines = f.read().replace("\r\n", "\n") |
| 54 | 54 |
| 55 try: | 55 try: |
| 56 # handle text files with \r\n line endings | 56 # handle text files with \r\n line endings |
| 57 config_lines.index("\r") | 57 config_lines.index("\r", 0, 100) |
| 58 config_lines = config_lines.replace("\r\n", "\n") | 58 config_lines = config_lines.replace("\r\n", "\n") |
| 59 except ValueError: | 59 except ValueError: |
| 60 pass | 60 pass |
| 61 | 61 |
| 62 self.assertIn("backend = %s\n"%db, config_lines) | 62 self.assertIn("backend = %s\n"%db, config_lines) |
| 97 with open(self.home + "/config.ini", "r") as f: | 97 with open(self.home + "/config.ini", "r") as f: |
| 98 config_lines = f.read() | 98 config_lines = f.read() |
| 99 | 99 |
| 100 try: | 100 try: |
| 101 # handle text files with \r\n line endings | 101 # handle text files with \r\n line endings |
| 102 config_lines.index("\r") | 102 config_lines.index("\r", 0, 100) |
| 103 config_lines = config_lines.replace("\r\n", "\n") | 103 config_lines = config_lines.replace("\r\n", "\n") |
| 104 except ValueError: | 104 except ValueError: |
| 105 pass | 105 pass |
| 106 | 106 |
| 107 self.assertIn("template_engine = jinja2\n", config_lines) | 107 self.assertIn("template_engine = jinja2\n", config_lines) |
