[qa] fix unclosed files problems in tests.
This commit is contained in:
@ -20,7 +20,8 @@ def test_write_pickled_dict_to_file(tmpdir):
|
||||
context.step()
|
||||
context.stop()
|
||||
|
||||
assert pickle.loads(fs.open(filename, 'rb').read()) == {'foo': 'bar'}
|
||||
with fs.open(filename, 'rb') as fp:
|
||||
assert pickle.loads(fp.read()) == {'foo': 'bar'}
|
||||
|
||||
with pytest.raises(AttributeError):
|
||||
getattr(context, 'file')
|
||||
@ -28,8 +29,8 @@ def test_write_pickled_dict_to_file(tmpdir):
|
||||
|
||||
def test_read_pickled_list_from_file(tmpdir):
|
||||
fs, filename = open_fs(tmpdir), 'input.pkl'
|
||||
fs.open(filename,
|
||||
'wb').write(pickle.dumps([['a', 'b', 'c'], ['a foo', 'b foo', 'c foo'], ['a bar', 'b bar', 'c bar']]))
|
||||
with fs.open(filename, 'wb') as fp:
|
||||
fp.write(pickle.dumps([['a', 'b', 'c'], ['a foo', 'b foo', 'c foo'], ['a bar', 'b bar', 'c bar']]))
|
||||
|
||||
reader = PickleReader(path=filename)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user