Browse Source

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

Roland Haroutiounian 9 years ago
parent
commit
f1d819c254
2 changed files with 3 additions and 4 deletions
  1. 0
    2
      EditorialModel/model.py
  2. 3
    2
      EditorialModel/test/test_fieldgroups.py

+ 0
- 2
EditorialModel/model.py View File

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

+ 3
- 2
EditorialModel/test/test_fieldgroups.py View File

@@ -126,8 +126,9 @@ class TestInit(FieldGroupTestCase):
126 126
         # 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
127 127
         self.assertFalse(EM_TEST_OBJECT.component(baduid), msg="Should be False because fieldgroup with id " + str(baduid) + " should not exist")
128 128
         self.assertFalse(EM_TEST_OBJECT.component(badname), msg="Should be False because fieldgroup with id " + str(badname) + " should not exist")
129
-        self.assertFalse(EM_TEST_OBJECT.component(print), msg="Should be False when crazy arguments are given")
130
-        self.assertFalse(EM_TEST_OBJECT.component(['hello', 'world']), msg="Should be False when crazy arguments are given")
129
+        self.assertFalse(EM_TEST_OBJECT.component(print), msg="Should be False when a function name is given as argument")
130
+        with self.assertRaises(TypeError, msg="Should raise when crazy arguments are given"):
131
+            fieldgroup = EM_TEST_OBJECT.component(['hello', 'world'])
131 132
 
132 133
 
133 134
 '''

Loading…
Cancel
Save