@@ -207,7 +207,8 @@ class TestExtractCargoToml:
207207 def test_basic_extraction (self ):
208208 toml_content = b'[package]\n name = "foo"\n version = "1.0.0"\n '
209209 path = _make_crate_tarball ("foo" , "1.0.0" , toml_content )
210- result = extract_cargo_toml (path , "foo" , "1.0.0" )
210+ with open (path , "rb" ) as f :
211+ result = extract_cargo_toml (f , "foo" , "1.0.0" )
211212 assert result ["package" ]["name" ] == "foo"
212213 assert result ["package" ]["version" ] == "1.0.0"
213214
@@ -216,7 +217,8 @@ def test_with_dependencies(self):
216217 b'[package]\n name = "bar"\n version = "0.1.0"\n ' b'\n [dependencies]\n serde = "1.0"\n '
217218 )
218219 path = _make_crate_tarball ("bar" , "0.1.0" , toml_content )
219- result = extract_cargo_toml (path , "bar" , "0.1.0" )
220+ with open (path , "rb" ) as f :
221+ result = extract_cargo_toml (f , "bar" , "0.1.0" )
220222 assert "serde" in result ["dependencies" ]
221223
222224 def test_with_features (self ):
@@ -225,7 +227,8 @@ def test_with_features(self):
225227 b'\n [features]\n default = ["std"]\n std = []\n '
226228 )
227229 path = _make_crate_tarball ("baz" , "2.0.0" , toml_content )
228- result = extract_cargo_toml (path , "baz" , "2.0.0" )
230+ with open (path , "rb" ) as f :
231+ result = extract_cargo_toml (f , "baz" , "2.0.0" )
229232 assert result ["features" ] == {"default" : ["std" ], "std" : []}
230233
231234 def test_missing_cargo_toml_raises (self ):
@@ -241,18 +244,21 @@ def test_missing_cargo_toml_raises(self):
241244 tmp .flush ()
242245
243246 with pytest .raises (KeyError ):
244- extract_cargo_toml (tmp .name , "foo" , "1.0.0" )
247+ with open (tmp .name , "rb" ) as f :
248+ extract_cargo_toml (f , "foo" , "1.0.0" )
245249
246250 def test_with_rust_version (self ):
247251 toml_content = b'[package]\n name = "qux"\n version = "1.0.0"\n rust-version = "1.56.0"\n '
248252 path = _make_crate_tarball ("qux" , "1.0.0" , toml_content )
249- result = extract_cargo_toml (path , "qux" , "1.0.0" )
253+ with open (path , "rb" ) as f :
254+ result = extract_cargo_toml (f , "qux" , "1.0.0" )
250255 assert result ["package" ]["rust-version" ] == "1.56.0"
251256
252257 def test_with_links (self ):
253258 toml_content = b'[package]\n name = "zlib-sys"\n version = "0.1.0"\n links = "z"\n '
254259 path = _make_crate_tarball ("zlib-sys" , "0.1.0" , toml_content )
255- result = extract_cargo_toml (path , "zlib-sys" , "0.1.0" )
260+ with open (path , "rb" ) as f :
261+ result = extract_cargo_toml (f , "zlib-sys" , "0.1.0" )
256262 assert result ["package" ]["links" ] == "z"
257263
258264
0 commit comments