Mercurial > p > roundup > code
comparison test/test_admin.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 | 978285986b2c |
| children | 859c57bc8d91 |
comparison
equal
deleted
inserted
replaced
| 7584:a5629f6e7ec2 | 7585:227aca44fea5 |
|---|---|
| 59 """search for regexp in file. | 59 """search for regexp in file. |
| 60 If not found return false. If found return match. | 60 If not found return false. If found return match. |
| 61 """ | 61 """ |
| 62 with open(filename) as f: | 62 with open(filename) as f: |
| 63 contents = f.read() | 63 contents = f.read() |
| 64 | |
| 65 try: | |
| 66 # handle text files with \r\n line endings | |
| 67 contents.index("\r") | |
| 68 contents = contents.replace("\r\n", "\n") | |
| 69 except ValueError: | |
| 70 pass | |
| 64 | 71 |
| 65 m = re.search(regexp, contents, re.MULTILINE) | 72 m = re.search(regexp, contents, re.MULTILINE) |
| 66 | 73 |
| 67 if not m: return False | 74 if not m: return False |
| 68 | 75 |
