1- '''
1+ """
22Common tests for IOs:
33 * check presence of all necessary attr
44 * check types
1313gin.g-node.org and upload files at NeuralEnsemble/ephy_testing_data
1414data repo.
1515
16- '''
16+ """
1717
1818__test__ = False
1919
5555
5656
5757class BaseTestIO :
58- '''
58+ """
5959 This class make common tests for all IOs.
6060
6161 Several startegies:
6262 * for IO able to read write : test_write_then_read
6363 * for IO able to read write with hash conservation (optional):
6464 test_read_then_write
65- * for all IOs : test_assert_readed_neo_object_is_compliant
65+ * for all IOs : test_assert_read_neo_object_is_compliant
6666 2 cases:
6767 * files are at G-node and downloaded:
6868 download_test_files_if_not_present
6969 * files are generated by MyIO.write()
7070
71- '''
72- # ~ __test__ = False
71+ Note: When inheriting this class use it as primary superclass in
72+ combination with the unittest.TestCase as a 2nd superclass, e.g.
73+ `NewIOTestClass(BaseTestIO, unittest.TestCase):`
74+
75+ """
76+ # __test__ = False
7377
7478 # all IO test need to modify this:
7579 ioclass = None # the IOclass to be tested
@@ -214,7 +218,7 @@ def generic_io_object(self, filename=None, return_path=False, clean=False):
214218
215219 def read_file (self , filename = None , return_path = False , clean = False ,
216220 target = None , readall = False , lazy = False ):
217- '''
221+ """
218222 Read from the specified filename.
219223
220224 If filename is None, create a filename (default).
@@ -235,7 +239,7 @@ def read_file(self, filename=None, return_path=False, clean=False,
235239
236240 If readall is True, use the read_all_ method instead of the read_
237241 method. Default is False.
238- '''
242+ """
239243 ioobj , path = self .generic_io_object (filename = filename ,
240244 return_path = True , clean = clean )
241245 obj = read_generic (ioobj , target = target , lazy = lazy ,
@@ -247,7 +251,7 @@ def read_file(self, filename=None, return_path=False, clean=False,
247251
248252 def write_file (self , obj = None , filename = None , return_path = False ,
249253 clean = False , target = None ):
250- '''
254+ """
251255 Write the target object to a file using the given neo io object ioobj.
252256
253257 If filename is None, create a filename (default).
@@ -266,7 +270,7 @@ def write_file(self, obj=None, filename=None, return_path=False,
266270
267271 obj is the object to write. If obj is None, an object is created
268272 automatically for the io class.
269- '''
273+ """
270274 ioobj , path = self .generic_io_object (filename = filename ,
271275 return_path = True , clean = clean )
272276 obj = write_generic (ioobj , target = target , return_reader = False )
@@ -276,15 +280,15 @@ def write_file(self, obj=None, filename=None, return_path=False,
276280 return obj
277281
278282 def iter_io_objects (self , return_path = False , clean = False ):
279- '''
283+ """
280284 Return an iterable over the io objects created from files_to_test
281285
282286 If return_path is True, yield the full path of the file along with
283287 the io object. yield ioobj, path Default is False.
284288
285289 If clean is True, try to delete existing versions of the file
286290 before creating the io object. Default is False.
287- '''
291+ """
288292 return iter_generic_io_objects (ioclass = self .ioclass ,
289293 filenames = self .files_to_test ,
290294 directory = self .local_test_dir ,
@@ -293,7 +297,7 @@ def iter_io_objects(self, return_path=False, clean=False):
293297
294298 def iter_readers (self , target = None , readall = False ,
295299 return_path = False , return_ioobj = False , clean = False ):
296- '''
300+ """
297301 Return an iterable over readers created from files_to_test.
298302
299303 If return_path is True, return the full path of the file along with
@@ -310,7 +314,7 @@ def iter_readers(self, target=None, readall=False,
310314
311315 If readall is True, use the read_all_ method instead of the
312316 read_ method. Default is False.
313- '''
317+ """
314318 return iter_generic_readers (ioclass = self .ioclass ,
315319 filenames = self .files_to_test ,
316320 directory = self .local_test_dir ,
@@ -323,7 +327,7 @@ def iter_readers(self, target=None, readall=False,
323327 def iter_objects (self , target = None , return_path = False , return_ioobj = False ,
324328 return_reader = False , clean = False , readall = False ,
325329 lazy = False ):
326- '''
330+ """
327331 Iterate over objects read from the list of filenames in files_to_test.
328332
329333 If target is None, use the first supported_objects from ioobj
@@ -351,7 +355,7 @@ def iter_objects(self, target=None, return_path=False, return_ioobj=False,
351355
352356 If readall is True, use the read_all_ method instead of the read_
353357 method. Default is False.
354- '''
358+ """
355359 return iter_read_objects (ioclass = self .ioclass ,
356360 filenames = self .files_to_test ,
357361 directory = self .local_test_dir ,
@@ -427,26 +431,26 @@ def test_write_then_read(self):
427431 close_object_safe (ioobj2 )
428432
429433 def test_read_then_write (self ):
430- '''
434+ """
431435 Test for IO that are able to read and write, here %s:
432436 1 - Read a file
433437 2 Write object set in another file
434438 3 Compare the 2 files hash
435439
436440 NOTE: TODO: Not implemented yet
437- ''' % self .ioclass .__name__
441+ """ % self .ioclass .__name__
438442
439443 if not self .able_to_write_or_read (readwrite = True ):
440444 return
441445 # assert_file_contents_equal(a, b)
442446
443- def test_assert_readed_neo_object_is_compliant (self ):
444- '''
447+ def test_assert_read_neo_object_is_compliant (self ):
448+ """
445449 Reading %s files in `files_to_test` produces compliant objects.
446450
447451 Compliance test: neo.test.tools.assert_neo_object_is_compliant for
448452 lazy mode.
449- ''' % self .ioclass .__name__
453+ """ % self .ioclass .__name__
450454 for obj , path in self .iter_objects (lazy = False , return_path = True ):
451455 try :
452456 # Check compliance of the block
@@ -456,14 +460,14 @@ def test_assert_readed_neo_object_is_compliant(self):
456460 exc .args += ('from %s' % os .path .basename (path ), )
457461 raise
458462
459- def test_readed_with_lazy_is_compliant (self ):
460- '''
463+ def test_read_with_lazy_is_compliant (self ):
464+ """
461465 Reading %s files in `files_to_test` with `lazy` is compliant.
462466
463467 Test the reader with lazy = True.
464468 The schema must contain proxy objects.
465469
466- ''' % self .ioclass .__name__
470+ """ % self .ioclass .__name__
467471 # This is for files presents at G-Node or generated
468472 if self .ioclass .support_lazy :
469473 for obj , path in self .iter_objects (lazy = True , return_path = True ):
0 commit comments