From f8f9226e9415397dab621a1269c3ead66375f760 Mon Sep 17 00:00:00 2001 From: hugovk Date: Wed, 5 Mar 2014 01:01:27 +0200 Subject: [PATCH] Remove a couple of resource warnings from not closing files --- test_pylast.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test_pylast.py b/test_pylast.py index 19253c0..286bf7c 100755 --- a/test_pylast.py +++ b/test_pylast.py @@ -676,8 +676,10 @@ class TestPyLast(unittest.TestCase): lastfm_user = self.network.get_user(self.username) # Act - pickle.dump(lastfm_user, open("lastfm.txt.pkl", "wb")) - loaded_user = pickle.load(open("lastfm.txt.pkl", "rb")) + with open("lastfm.txt.pkl", "wb") as f: + pickle.dump(lastfm_user, f) + with open("lastfm.txt.pkl", "rb") as f: + loaded_user = pickle.load(f) # Assert self.assertEqual(lastfm_user, loaded_user)