From d5b536d51c25eb0ff75b4c2d65c4d3a080c87370 Mon Sep 17 00:00:00 2001 From: hugovk Date: Fri, 7 Mar 2014 10:35:24 +0200 Subject: [PATCH] Test: Use a unique filename for picking and delete it afterwards. Allows concurrent testing. --- test_pylast.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test_pylast.py b/test_pylast.py index a01f4d4..56bd78d 100755 --- a/test_pylast.py +++ b/test_pylast.py @@ -643,12 +643,14 @@ class TestPyLast(unittest.TestCase): # Arrange import pickle lastfm_user = self.network.get_user(self.username) + filename = str(self.unix_timestamp()) + ".pkl" # Act - with open("lastfm.txt.pkl", "wb") as f: + with open(filename, "wb") as f: pickle.dump(lastfm_user, f) - with open("lastfm.txt.pkl", "rb") as f: + with open(filename, "rb") as f: loaded_user = pickle.load(f) + os.remove(filename) # Assert self.assertEqual(lastfm_user, loaded_user) @@ -1290,7 +1292,7 @@ class TestPyLast(unittest.TestCase): if __name__ == '__main__': # For quick testing of a single case (eg. test = "test_scrobble") - test = "test_geo_get_events_in_latlong" + test = "" if test is not None and len(test): suite = unittest.TestSuite()