Test: Use a unique filename for picking and delete it afterwards. Allows concurrent testing.
This commit is contained in:
parent
5d62680753
commit
d5b536d51c
|
@ -643,12 +643,14 @@ class TestPyLast(unittest.TestCase):
|
||||||
# Arrange
|
# Arrange
|
||||||
import pickle
|
import pickle
|
||||||
lastfm_user = self.network.get_user(self.username)
|
lastfm_user = self.network.get_user(self.username)
|
||||||
|
filename = str(self.unix_timestamp()) + ".pkl"
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
with open("lastfm.txt.pkl", "wb") as f:
|
with open(filename, "wb") as f:
|
||||||
pickle.dump(lastfm_user, 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)
|
loaded_user = pickle.load(f)
|
||||||
|
os.remove(filename)
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
self.assertEqual(lastfm_user, loaded_user)
|
self.assertEqual(lastfm_user, loaded_user)
|
||||||
|
@ -1290,7 +1292,7 @@ class TestPyLast(unittest.TestCase):
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
# For quick testing of a single case (eg. test = "test_scrobble")
|
# 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):
|
if test is not None and len(test):
|
||||||
suite = unittest.TestSuite()
|
suite = unittest.TestSuite()
|
||||||
|
|
Loading…
Reference in a new issue