From 2a89801701d21368014394c4698128233913fdea Mon Sep 17 00:00:00 2001 From: Ian Rees Date: Tue, 26 May 2015 13:25:13 -0700 Subject: [PATCH] Change base Entity name() and id() to return None instead of NotImplementedError --- mzgtfs/entity.py | 7 +++++-- mzgtfs/test_entity.py | 6 ++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/mzgtfs/entity.py b/mzgtfs/entity.py index 3a90ad5..e220ae5 100644 --- a/mzgtfs/entity.py +++ b/mzgtfs/entity.py @@ -30,6 +30,9 @@ def __init__(self, **data): self._children = set() self._parents = set() + def __repr__(self): + return '<%s %s>'%(self.__class__.__name__, self.id()) + # GTFS row data. def __len__(self): return len(self.data) @@ -77,11 +80,11 @@ def items(self): # Name methods. def name(self): """A reasonable name for the entity.""" - raise NotImplementedError + return None def id(self): """An internal GTFS identifier, e.g. route_id.""" - raise NotImplementedError + return None def feedid(self, feedid): """A canonical Onestop-style ID for this entity.""" diff --git a/mzgtfs/test_entity.py b/mzgtfs/test_entity.py index fa953de..519d1c4 100644 --- a/mzgtfs/test_entity.py +++ b/mzgtfs/test_entity.py @@ -60,13 +60,11 @@ def test_setitem_ntconvert(self): def test_name(self): entity = entities.Entity(**self.expect) - with self.assertRaises(NotImplementedError): - entity.name() + assert entity.name() is None def test_id(self): entity = entities.Entity(**self.expect) - with self.assertRaises(NotImplementedError): - entity.id() + assert entity.id() is None def test_point(self): entity = entities.Entity(**self.expect)