Skip to content

Commit

Permalink
tests were failing
Browse files Browse the repository at this point in the history
  • Loading branch information
mvexel committed Jan 27, 2025
1 parent beaf934 commit cada06f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
18 changes: 15 additions & 3 deletions src/osmdiff/augmenteddiff.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from posixpath import join as urljoin
from xml.etree import cElementTree
from xml.etree import ElementTree
from datetime import datetime
from typing import Optional
import time
Expand Down Expand Up @@ -119,7 +119,10 @@ def get_state(self) -> bool:
True if state was successfully retrieved, False otherwise
"""
state_url = urljoin(self.base_url, "augmented_diff_status")
response = requests.get(state_url, timeout=5)
response = requests.get(
state_url,
timeout=self.timeout or 5 # Use instance timeout with fallback
)
if response.status_code != 200:
return False
self.sequence_number = int(response.text)
Expand Down Expand Up @@ -170,7 +173,7 @@ def _build_action(self, elem):
self.delete.append({"old": osm_obj_old})

def _parse_stream(self, stream):
for event, elem in cElementTree.iterparse(stream):
for event, elem in ElementTree.iterparse(stream):
if elem.tag == "remark":
self._remarks.append(elem.text)
if elem.tag == "meta":
Expand Down Expand Up @@ -287,3 +290,12 @@ def __repr__(self):
{delete} deleted)".format(
create=len(self.create), modify=len(self.modify), delete=len(self.delete)
)

def __enter__(self):
return self

def __exit__(self, exc_type, exc_val, exc_tb):
"""Clear all changes when exiting context."""
self.create.clear()
self.modify.clear()
self.delete.clear()
6 changes: 3 additions & 3 deletions src/osmdiff/osm/osm.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ class OSMObject:

def __init__(self, tags: Dict[str, str] = {}, attribs: Dict[str, str] = {}, bounds: List[float] = None) -> None:
"""Initialize an empty OSM object."""
self.tags = tags
self.attribs = attribs
self.bounds = bounds
self.tags = tags or {}
self.attribs = attribs or {}
self.bounds = bounds or None

def __repr__(self) -> str:
"""
Expand Down

0 comments on commit cada06f

Please sign in to comment.