Skip to content

Commit 156158d

Browse files
[tests] Add a reproducer for #2368
1 parent 7f2b8cf commit 156158d

4 files changed

Lines changed: 39 additions & 0 deletions

File tree

tests/regrtest_data/duplicate_code/2368/__init__.py

Whitespace-only changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""Database utilities."""
2+
3+
4+
def setup_connection(host, port, database):
5+
"""Set up a database connection with retries."""
6+
retries = 3
7+
timeout = 30
8+
connection_string = f"{host}:{port}/{database}"
9+
print(f"Connecting to {connection_string}")
10+
for attempt in range(retries):
11+
print(f"Attempt {attempt + 1} of {retries}")
12+
if attempt > 0:
13+
print(f"Waiting {timeout} seconds before retry")
14+
return connection_string
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""Project utilities."""
2+
3+
4+
def setup_connection(host, port, database):
5+
"""Set up a database connection with retries."""
6+
retries = 3
7+
timeout = 30
8+
connection_string = f"{host}:{port}/{database}"
9+
print(f"Connecting to {connection_string}")
10+
for attempt in range(retries):
11+
print(f"Attempt {attempt + 1} of {retries}")
12+
if attempt > 0:
13+
print(f"Waiting {timeout} seconds before retry")
14+
return connection_string
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""XML generation — no duplicate code here."""
2+
import xml.etree.ElementTree as ET
3+
4+
5+
def generate_xml(data):
6+
"""Generate an XML document from data."""
7+
root = ET.Element("root")
8+
for key, value in data.items():
9+
child = ET.SubElement(root, key)
10+
child.text = str(value)
11+
return ET.tostring(root, encoding="unicode")

0 commit comments

Comments
 (0)