2929 assert_sub_schema_is_lazy_loaded ,
3030 assert_children_empty )
3131
32- from neo .test .rawiotest .tools import (can_use_network , make_all_directories ,
33- download_test_file , create_local_temp_dir )
32+ from neo .test .rawiotest .tools import can_use_network
33+ from neo .test .rawiotest .common_rawio_test import repo_for_test
34+ from neo .utils import (download_dataset ,
35+ get_local_testing_data_folder , HAVE_DATALAD )
36+
3437
3538from neo .test .iotest .tools import (cleanup_test_file ,
3639 close_object_safe , create_generic_io_object ,
4043 iter_generic_readers , iter_read_objects ,
4144 read_generic ,
4245 write_generic )
43- from neo .test .generate_datasets import generate_from_supported_objects
44-
4546
46- # url_for_tests = "https://portal.g-node.org/neo/" #This is the old place
47- url_for_tests = "https://web.gin.g-node.org/NeuralEnsemble/ephy_testing_data/raw/master/"
47+ from neo .test .generate_datasets import generate_from_supported_objects
4848
4949
5050class BaseTestIO :
@@ -67,8 +67,8 @@ class BaseTestIO:
6767 # all IO test need to modify this:
6868 ioclass = None # the IOclass to be tested
6969
70- files_to_test = [] # list of files to test compliances
71- files_to_download = [] # when files are at G-Node
70+ entities_to_test = [] # list of files to test compliances
71+ entities_to_download = [] # when files are at gin
7272
7373 # when reading then writing produces files with identical hashes
7474 hash_conserved_when_write_read = False
@@ -84,7 +84,6 @@ def setUp(self):
8484 '''
8585 Set up the test fixture. This is run for every test
8686 '''
87- self .files_to_test = copy (self .__class__ .files_to_test )
8887 self .higher = self .ioclass .supported_objects [0 ]
8988 self .shortname = self .ioclass .__name__ .lower ().rstrip ('io' )
9089 # these objects can both be written and read
@@ -93,11 +92,19 @@ def setUp(self):
9392 # these objects can be either written or read
9493 self .io_readorwrite = list (set (self .ioclass .readable_objects ) |
9594 set (self .ioclass .writeable_objects ))
96- self .create_local_dir_if_not_exists ()
97- self .download_test_files_if_not_present ()
98- self .files_generated = []
99- self .generate_files_for_io_able_to_write ()
100- self .files_to_test .extend (self .files_generated )
95+
96+ if HAVE_DATALAD :
97+ for remote_path in self .entities_to_download :
98+ download_dataset (repo = repo_for_test , remote_path = remote_path )
99+
100+ self .files_generated = []
101+ self .generate_files_for_io_able_to_write ()
102+
103+ # be carefull self.entities_to_test is class attributes
104+ self .files_to_test = [self .get_local_path (e ) for e in self .entities_to_test ]
105+ else :
106+ self .files_to_test = []
107+ raise unittest .SkipTest ("Requires datalad download of data from the web" )
101108
102109 def create_local_dir_if_not_exists (self ):
103110 '''
@@ -169,11 +176,15 @@ def able_to_write_or_read(self, writeread=False, readwrite=False):
169176
170177 return True
171178
172- def get_filename_path (self , filename ):
173- '''
174- Get the path to a filename in the current temporary file directory
175- '''
176- return os .path .join (self .local_test_dir , filename )
179+ def get_local_base_folder (self ):
180+ return get_local_testing_data_folder ()
181+
182+ def get_local_path (self , sub_path ):
183+ root_local_path = self .get_local_base_folder ()
184+ local_path = root_local_path / sub_path
185+ # TODO later : remove the str when all IOs handle the pathlib.Path objects
186+ local_path = str (local_path )
187+ return local_path
177188
178189 def generic_io_object (self , filename = None , return_path = False , clean = False ):
179190 '''
0 commit comments