From: kaliko Date: Tue, 7 Jun 2016 14:33:01 +0000 (+0200) Subject: More robust Meta Object X-Git-Tag: 0.14.2~5 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=031f1da47546ebf12f6e74467fcf4824ea4a26a3;hp=da5d3f40492830ca7ef436918500a68ab0600927;p=mpd-sima.git More robust Meta Object Controls name attribute is str type --- diff --git a/sima/lib/meta.py b/sima/lib/meta.py index 069a904..2877b2f 100644 --- a/sima/lib/meta.py +++ b/sima/lib/meta.py @@ -82,7 +82,9 @@ class Meta: self.__aliases = set() self.log = logging.getLogger(__name__) if 'name' not in kwargs or not kwargs.get('name'): - raise MetaException('Need a "name" argument') + raise MetaException('Need a "name" argument (str type)') + elif not isinstance(kwargs.get('name'), str): + raise MetaException('"name" argument not a string') else: self.__name = kwargs.pop('name') if 'mbid' in kwargs and kwargs.get('mbid'): diff --git a/tests/test_meta.py b/tests/test_meta.py index acdec38..a615a18 100644 --- a/tests/test_meta.py +++ b/tests/test_meta.py @@ -20,7 +20,7 @@ class TestMetaObject(unittest.TestCase): for args in [ {'mbid':VALID}, {'name': None}, - {}, + {'name': 42}, ]: with self.assertRaises(MetaException, msg='{} does not raise an except.'.format(args)):