3
3
import tempfile
4
4
import zipfile
5
5
from contextlib import contextmanager
6
+ from pathlib import Path
6
7
7
8
import pytest
8
9
@@ -101,7 +102,7 @@ def test_openfile_open(m):
101
102
assert m .size ("somepath" ) == 5
102
103
103
104
104
- def test_open_local ():
105
+ def test_open_local_w_cache ():
105
106
d1 = str (tempfile .mkdtemp ())
106
107
f1 = os .path .join (d1 , "f1" )
107
108
open (f1 , "w" ).write ("test1" )
@@ -112,6 +113,45 @@ def test_open_local():
112
113
assert d2 in fn
113
114
114
115
116
+ def test_open_local_w_magic ():
117
+ d1 = str (tempfile .mkdtemp ())
118
+ f1 = os .path .join (d1 , "f1" )
119
+ open (f1 , "w" ).write ("test1" )
120
+ fn = open_local (os .path .join (d1 , "f*" ))
121
+ assert len (fn ) == 1
122
+ assert isinstance (fn , list )
123
+
124
+
125
+ def test_open_local_w_list_of_str ():
126
+ d1 = str (tempfile .mkdtemp ())
127
+ f1 = os .path .join (d1 , "f1" )
128
+ open (f1 , "w" ).write ("test1" )
129
+ fn = open_local ([f1 , f1 ])
130
+ assert len (fn ) == 2
131
+ assert isinstance (fn , list )
132
+ assert all (isinstance (elem , str ) for elem in fn )
133
+
134
+
135
+ def test_open_local_w_path ():
136
+ d1 = str (tempfile .mkdtemp ())
137
+ f1 = os .path .join (d1 , "f1" )
138
+ open (f1 , "w" ).write ("test1" )
139
+ p = Path (f1 )
140
+ fn = open_local (p )
141
+ assert isinstance (fn , str )
142
+
143
+
144
+ def test_open_local_w_list_of_path ():
145
+ d1 = str (tempfile .mkdtemp ())
146
+ f1 = os .path .join (d1 , "f1" )
147
+ open (f1 , "w" ).write ("test1" )
148
+ p = Path (f1 )
149
+ fn = open_local ([p , p ])
150
+ assert len (fn ) == 2
151
+ assert isinstance (fn , list )
152
+ assert all (isinstance (elem , str ) for elem in fn )
153
+
154
+
115
155
def test_xz_lzma_compressions ():
116
156
pytest .importorskip ("lzma" )
117
157
# Ensure that both 'xz' and 'lzma' compression names can be parsed
0 commit comments