1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2026-06-30 04:50:48 +02:00

[EmFieldGroup] Changed the assertions for the init tests with bad arguments

This commit is contained in:
Roland Haroutiounian 2015-07-30 15:11:28 +02:00
commit f1d819c254
2 changed files with 3 additions and 4 deletions

View file

@ -104,8 +104,6 @@ class Model(object):
# @param uid int : An EmComponent uid
# @return The corresponding instance or False if uid don't exists
def component(self, uid):
if not isinstance(uid, int) or not isinstance(uid, str):
raise TypeError
return False if uid not in self._components['uids'] else self._components['uids'][uid]
## Sort components by rank in Model::_components

View file

@ -126,8 +126,9 @@ class TestInit(FieldGroupTestCase):
# TODO Voir si on garde le return False de Model.component() ou si on utilise plutôt une exception EmComponentNotExistError en modifiant le reste du code source pour gérer ce cas
self.assertFalse(EM_TEST_OBJECT.component(baduid), msg="Should be False because fieldgroup with id " + str(baduid) + " should not exist")
self.assertFalse(EM_TEST_OBJECT.component(badname), msg="Should be False because fieldgroup with id " + str(badname) + " should not exist")
self.assertFalse(EM_TEST_OBJECT.component(print), msg="Should be False when crazy arguments are given")
self.assertFalse(EM_TEST_OBJECT.component(['hello', 'world']), msg="Should be False when crazy arguments are given")
self.assertFalse(EM_TEST_OBJECT.component(print), msg="Should be False when a function name is given as argument")
with self.assertRaises(TypeError, msg="Should raise when crazy arguments are given"):
fieldgroup = EM_TEST_OBJECT.component(['hello', 'world'])
'''