Browse Source

🎨 Auto format

pull/15327/head
pre-commit-ci-lite[bot] 3 months ago
committed by GitHub
parent
commit
84353509f0
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 18
      fix_snapshot.py

18
fix_snapshot.py

@ -1,10 +1,8 @@
#!/usr/bin/env python3
"""Remove the old snapshot dictionary from test_include_router_defaults_overrides.py"""
import re
# Read the file
with open('tests/test_include_router_defaults_overrides.py', 'r') as f:
with open("tests/test_include_router_defaults_overrides.py") as f:
lines = f.readlines()
# Find and remove the old snapshot dictionary
@ -13,27 +11,27 @@ i = 0
while i < len(lines):
line = lines[i]
new_lines.append(line)
# If we hit operation_ids.add(op_id), the next non-empty line should be the start of the snapshot dict
if 'operation_ids.add(op_id)' in line:
if "operation_ids.add(op_id)" in line:
# Skip all lines until we find the closing paren of snapshot()
i += 1
brace_count = 0
while i < len(lines):
cur_line = lines[i]
brace_count += cur_line.count('{') - cur_line.count('}')
brace_count += cur_line.count("{") - cur_line.count("}")
# Check if this is the closing paren of snapshot()
if brace_count == 0 and cur_line.strip() == ')':
if brace_count == 0 and cur_line.strip() == ")":
i += 1
break
i += 1
continue
i += 1
# Write back
with open('tests/test_include_router_defaults_overrides.py', 'w') as f:
with open("tests/test_include_router_defaults_overrides.py", "w") as f:
f.writelines(new_lines)
print("Done! Removed snapshot dictionary")

Loading…
Cancel
Save