Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion osm/osm_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class OSMWay:
highway: str = field(init=False, default="")
area: Optional[str] = field(init=False, default=None)
max_speed_str: Optional[str] = field(init=False, default=None)
max_speed_int: int = field(init=False)
max_speed_int: int = field(init=False, default=0)
direction: str = field(init=False, default="")
forward: bool = field(init=False, default=True)
backward: bool = field(init=False, default=True)
Expand Down
4 changes: 4 additions & 0 deletions tests/convert_graph_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import importlib.util
import random
import string
import unittest
Expand All @@ -6,6 +7,8 @@
from graph.graph import Graph
from graph.graph_types import Edge, EdgeData, Vertex, VertexData

networkx_available = importlib.util.find_spec("networkx") is not None


def random_string(length=8):
return "".join(random.choice(string.ascii_lowercase) for i in range(length))
Expand All @@ -15,6 +18,7 @@ def random_uint(max_val=1000):
return random.randint(1, max_val)


@unittest.skipUnless(networkx_available, "networkx is an optional dependency and is not installed")
class TestConvertGraphTest(unittest.TestCase):
def test_converting_K4_graph(self):
g = self.create_graph(number_nodes=4)
Expand Down
21 changes: 9 additions & 12 deletions tests/integration_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import importlib.util
import unittest
from subprocess import call

networkx_available = importlib.util.find_spec("networkx") is not None


class IntegrationTest(unittest.TestCase):
def test_python(self):
Expand All @@ -21,18 +24,12 @@ def pedestrian_graph_contracted_ok(self):
self.assertEqual(nmb_edges, 2039)

def _execute_program(self):
returncode = call(
[
"python3",
"run.py",
"-f",
"data/karlsruhe_small.osm",
"-n",
"p",
"-c",
"--networkx",
]
)
args = ["python3", "run.py", "-f", "data/karlsruhe_small.osm", "-n", "p", "-c"]
# --networkx requires the optional networkx dependency; only exercise
# it when networkx is actually installed
if networkx_available:
args.append("--networkx")
returncode = call(args)
self.assertEqual(0, returncode)

def _get_nmb_nodes_edges(self, path):
Expand Down
Loading