diff options
author | Alexis Hildebrandt <afh@surryhill.net> | 2024-02-25 17:40:19 +0100 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2024-07-08 10:12:07 -0700 |
commit | 815305b94864556c994934c7a7c830da7de1d94e (patch) | |
tree | 6d85f089b05520416eee1f51f80636b357cda73d /test/ConfirmTests.py | |
parent | 0b561c7304ec82807212bd070fc6a1684c67607b (diff) | |
download | fork-ledger-815305b94864556c994934c7a7c830da7de1d94e.tar.gz fork-ledger-815305b94864556c994934c7a7c830da7de1d94e.tar.bz2 fork-ledger-815305b94864556c994934c7a7c830da7de1d94e.zip |
Use Python raw strings for regex methods argument
Diffstat (limited to 'test/ConfirmTests.py')
-rwxr-xr-x | test/ConfirmTests.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/test/ConfirmTests.py b/test/ConfirmTests.py index 54187130..a856f2fc 100755 --- a/test/ConfirmTests.py +++ b/test/ConfirmTests.py @@ -32,8 +32,8 @@ commands = [ ] def clean(num): - num = re.sub("(\s+|\$|,)","", num) - m = re.search("([-0-9.]+)", num) + num = re.sub(r'(\s+|\$|,)',"", num) + m = re.search(r'([-0-9.]+)', num) if m: return float(m.group(1)) else: @@ -45,10 +45,10 @@ def confirm_report(command): failure = False running_total = 0.0 - p = harness.run(re.sub('\$cmd', 'reg', command)) + p = harness.run(re.sub(r'\$cmd', 'reg', command)) for line in harness.readlines(p.stdout): - match = re.match("\\s*([-$,0-9.]+)\\s+([-$,0-9.]+)", line[54:]) + match = re.match(r'\\s*([-$,0-9.]+)\\s+([-$,0-9.]+)', line[54:]) if not match: continue @@ -57,7 +57,7 @@ def confirm_report(command): running_total += value diff = abs(running_total - total) - if re.search(' -[VGB] ', command) and diff < 0.015: + if re.search(r' -[VGB] ', command) and diff < 0.015: diff = 0.0 if diff > 0.001: print("DISCREPANCY: %.3f (%.3f - %.3f) at line %d:" % \ @@ -71,14 +71,14 @@ def confirm_report(command): balance_total = 0.0 - p = harness.run(re.sub('\$cmd', 'bal', command)) + p = harness.run(re.sub(r'\$cmd', 'bal', command)) for line in harness.readlines(p.stdout): if line[0] != '-': balance_total = clean(line[:20]) diff = abs(balance_total - running_total) - if re.search(' -[VGB] ', command) and diff < 0.015: + if re.search(r' -[VGB] ', command) and diff < 0.015: diff = 0.0 if diff > 0.001: print() @@ -90,7 +90,7 @@ def confirm_report(command): return not failure for cmd in commands: - if confirm_report('$ledger --rounding $cmd ' + re.sub('\$tests', str(args.tests), cmd)): + if confirm_report('$ledger --rounding $cmd ' + re.sub(r'\$tests', str(args.tests), cmd)): harness.success() else: harness.failure() |