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:
hugovk 2014-03-03 21:54:35 +02:00
parent c15923e4cd
commit b947179972
2 changed files with 30 additions and 0 deletions

2
.gitignore vendored
View file

@ -52,4 +52,6 @@ coverage.xml
# Sphinx documentation
docs/_build/
# Test files
test_pylast.yaml
lastfm.txt.pkl

View file

@ -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")