Browse Source

clean direction test

Bastien Sevajol 9 years ago
parent
commit
ad7ef0c84f
1 changed files with 7 additions and 16 deletions
  1. 7 16
      intelligine/tests/simulation/molecule/TestDirection.py

+ 7 - 16
intelligine/tests/simulation/molecule/TestDirection.py View File

184
 
184
 
185
     def test_no_molecules_around(self):
185
     def test_no_molecules_around(self):
186
         # No molecule
186
         # No molecule
187
-        try:  # WTF ?
188
-            self.assertRaises(NoMolecule, self._test_direction_for_points({}, -1))
189
-        except NoMolecule:
190
-            self.assertTrue(True)
187
+        with self.assertRaises(NoMolecule):
188
+            self._test_direction_for_points({}, -1)
191
 
189
 
192
         # Wrong molecule type
190
         # Wrong molecule type
193
-        try:  # WTF ?
194
-            self.assertRaises(NoMolecule, self._test_direction_for_points({
191
+        with self.assertRaises(NoMolecule):
192
+            self._test_direction_for_points({
195
                 _p(SOUTH_EST): {MOLECULES_DIRECTION: {PHEROMON_DIR_NONE: (9, 5, 0)}}
193
                 _p(SOUTH_EST): {MOLECULES_DIRECTION: {PHEROMON_DIR_NONE: (9, 5, 0)}}
196
-            }, -1))
197
-        except NoMolecule:
198
-            self.assertTrue(True)
194
+            }, -1)
199
 
195
 
200
     def test_appose(self):
196
     def test_appose(self):
201
         self._test_point_raise_no_molecule()
197
         self._test_point_raise_no_molecule()
217
         self._test_direction_for_points({}, NORTH, re_init=False)
213
         self._test_direction_for_points({}, NORTH, re_init=False)
218
         self._test_direction_for_point({}, NORTH, re_init=False)
214
         self._test_direction_for_point({}, NORTH, re_init=False)
219
 
215
 
220
-
221
     def _test_point_raise_no_molecule(self, molecules={}, direction=-1, molecule_type=PHEROMON_DIR_EXPLO,
216
     def _test_point_raise_no_molecule(self, molecules={}, direction=-1, molecule_type=PHEROMON_DIR_EXPLO,
222
                                  reference_point=_p(CENTER), re_init=True):
217
                                  reference_point=_p(CENTER), re_init=True):
223
-        try:  # WTF ?
218
+        with self.assertRaises(NoMolecule):
224
             self._test_direction_for_point(molecules, direction, re_init=re_init)
219
             self._test_direction_for_point(molecules, direction, re_init=re_init)
225
-        except NoMolecule:
226
-            self.assertTrue(True)
227
 
220
 
228
     def _test_points_raise_no_molecule(self, molecules={}, direction=-1, molecule_type=PHEROMON_DIR_EXPLO,
221
     def _test_points_raise_no_molecule(self, molecules={}, direction=-1, molecule_type=PHEROMON_DIR_EXPLO,
229
                                  reference_point=_p(CENTER), re_init=True):
222
                                  reference_point=_p(CENTER), re_init=True):
230
-        try:  # WTF ?
223
+        with self.assertRaises(NoMolecule):
231
             self._test_direction_for_points(molecules, direction, re_init=re_init)
224
             self._test_direction_for_points(molecules, direction, re_init=re_init)
232
-        except NoMolecule:
233
-            self.assertTrue(True)
234
 
225
 
235
     def _get_molecule(self, type, distance):
226
     def _get_molecule(self, type, distance):
236
         return Molecule(MOLECULES_DIRECTION, type, distance=distance)
227
         return Molecule(MOLECULES_DIRECTION, type, distance=distance)