Test pickle and cpickle on User object. Seems to work, so going to close #83 and can re-open if more specific info is given.
This commit is contained in:
parent
c15923e4cd
commit
b947179972
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -52,4 +52,6 @@ coverage.xml
|
|||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# Test files
|
||||
test_pylast.yaml
|
||||
lastfm.txt.pkl
|
||||
|
|
|
@ -662,6 +662,34 @@ class TestPyLast(unittest.TestCase):
|
|||
self.helper_upcoming_events_have_valid_ids(venue)
|
||||
|
||||
|
||||
def helper_test_pickle(self, pickle):
|
||||
# Arrange
|
||||
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"))
|
||||
|
||||
# Assert
|
||||
self.assertEqual(lastfm_user, loaded_user)
|
||||
|
||||
|
||||
def test_pickle(self):
|
||||
# Arrange
|
||||
import pickle
|
||||
|
||||
# Act/Assert
|
||||
self.helper_test_pickle(pickle)
|
||||
|
||||
|
||||
def test_cpickle(self):
|
||||
# Arrange
|
||||
import cPickle as pickle
|
||||
|
||||
# Act/Assert
|
||||
self.helper_test_pickle(pickle)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# For quick testing of a single case (eg. test = "test_scrobble")
|
||||
|
|
Loading…
Reference in a new issue