@@ -40,10 +40,31 @@ def test_available_backends_data():
4040
4141
4242def test_unavailable_data_backend ():
43- with pytest .raises (KeyError ):
43+ with pytest .raises (
44+ KeyError , match = re .escape ("option='junk' is not supported. Available options:" )
45+ ):
4446 DATA_BACKENDS .get_instance ("junk" )
4547
4648
49+ def test_guess_backend_data ():
50+ assert isinstance (DATA_BACKENDS .guess_backend ("0.csv" ), CSVDataBackend )
51+ assert isinstance (DATA_BACKENDS .guess_backend ("0.feather" ), FeatherDataBackend )
52+ assert isinstance (DATA_BACKENDS .guess_backend ("0.in-mem" ), InMemoryDataBackend )
53+ assert isinstance (DATA_BACKENDS .guess_backend ("0.nc" ), netCDFDataBackend )
54+
55+
56+ def test_guess_data_backend_error ():
57+ with pytest .raises (
58+ ValueError ,
59+ match = re .escape (
60+ "Could not guess backend from data_file_name='0.junk'. "
61+ "The file's extension does not match any of the available options: "
62+ "known_options_and_extensions="
63+ ),
64+ ):
65+ DATA_BACKENDS .guess_backend ("0.junk" )
66+
67+
4768def test_available_backends_index ():
4869 assert isinstance (INDEX_BACKENDS .get_instance ("csv" ), CSVIndexBackend )
4970 assert isinstance (INDEX_BACKENDS .get_instance ("feather" ), FeatherIndexBackend )
@@ -52,10 +73,31 @@ def test_available_backends_index():
5273
5374
5475def test_unavailable_index_backend ():
55- with pytest .raises (KeyError ):
76+ with pytest .raises (
77+ KeyError , match = re .escape ("option='junk' is not supported. Available options:" )
78+ ):
5679 INDEX_BACKENDS .get_instance ("junk" )
5780
5881
82+ def test_guess_backend_index ():
83+ assert isinstance (INDEX_BACKENDS .guess_backend ("0.csv" ), CSVIndexBackend )
84+ assert isinstance (INDEX_BACKENDS .guess_backend ("0.feather" ), FeatherIndexBackend )
85+ assert isinstance (INDEX_BACKENDS .guess_backend ("0.in-mem" ), InMemoryIndexBackend )
86+ assert isinstance (INDEX_BACKENDS .guess_backend ("0.nc" ), netCDFIndexBackend )
87+
88+
89+ def test_guess_index_backend_error ():
90+ with pytest .raises (
91+ ValueError ,
92+ match = re .escape (
93+ "Could not guess backend from index_file_name='index.junk'. "
94+ "The file's extension does not match any of the available options: "
95+ "known_options_and_extensions="
96+ ),
97+ ):
98+ INDEX_BACKENDS .guess_backend ("index.junk" )
99+
100+
59101def test_filelock_not_available_default_initialisation (tmpdir ):
60102 with patch .dict (sys .modules , {"filelock" : None }):
61103 with pytest .raises (
0 commit comments