Esempio n. 1
0
 def test_mixed_pickled_list_matches_original(self):
     test_list = [1, 2, 'red', 'blue']
     with open('testfile.p', 'w') as f:
         list_pickler(test_list, f)
     with open('testfile.p', 'r') as f:
         unpickled = unpickler(f)
     self.assertEqual(test_list, unpickled)
Esempio n. 2
0
 def test_pickled_list_of_strings_matches_original(self):
     test_list = ['one', 'two', 'three', 'four']
     with open('testfile.p', 'w') as f:
         list_pickler(test_list, f)
     with open('testfile.p', 'r') as f:
         unpickled = unpickler(f)
     self.assertEqual(test_list, unpickled)
Esempio n. 3
0
 def test_pickled_list_of_numbers_matches_original(self):
     test_list = [1, 2, 3, 4]
     with open('testfile.p', 'w') as f:
         list_pickler(test_list, f)
     with open('testfile.p', 'r') as f:
         unpickled = unpickler(f)
     self.assertEqual(test_list, unpickled)
Esempio n. 4
0
    def pickle_unpickle_equal_test(self):

        my_list = [1, 2, "sherman Wosely"]
        #list_pickler(my_list, self.file_obj)
        list_pickler(my_list, self.file_name )
        another_list = unpickler(self.file_name)

        # check that my_list and another list are equal
        self.assertEqual(True, my_list == another_list)
Esempio n. 5
0
def test_original_and_unpickled_list_same(self):
list_pickler(self.file, self.my_list)
unpickled_list = unpickler(self.file)
self.assertEqual(self.my_list, unpickled_list)

def tearDown(self): # tearDown gets run after the tests have been run,
# whether they fail or pass. In this case, we're
# using tear down to delete our temp folder and its
# contents
shutil.rmtree(self.path) #shutil.rmtree deletes a directory and all its contents
Esempio n. 6
0
 def test_lists_equal_using_pickle(self):
     my_list = ['R', 'a', 'l', 'p', 'h']
     file_pickled = open('pickle_test.txt', 'w') #open file if exists, create it otherwise
     list_pickler(my_list, file_pickled)
     file_pickled.close()
     file_pickled = open('pickle_test.txt', 'r') #open file for reading
     unpickled_list = unpickler(file_pickled)
     file_pickled.close()
     remove('pickle_test.txt') #delete file
     self.assertEqual(my_list, unpickled_list)
Esempio n. 7
0
    def pickled_list_no_change_test(self):

        #old code - ignore me
        #tester = open('pickle_test.p','r+')
        #my_list = ["cheese","ham"]
        #pickle.dump(my_list,tester)
        #another_list = pickle.load(tester)
        #tester.close()
        my_list = ["cheese","ham"]
        file_loc = list_pickler(my_list)
        another_list = unpickler(file_loc)

        self.assertEqual(my_list,another_list)
Esempio n. 8
0
	def test_pickle(self):
		color=[1,2,3,4]
		list_pickler=list_pickler()
		result=list_pickler.pickler(color)
		self.assertEqual(result,[1,2,3,4])
		
#import pickle

#favorite_color=[1,2,3,4]

#pickle.dump(favorite_color, open("save.p","wb"))

#favorite_color_unpickled=pickle.load(open("save.p","rb")
Esempio n. 9
0
    def test_pickle(self):
        color = [1, 2, 3, 4]
        list_pickler = list_pickler()
        result = list_pickler.pickler(color)
        self.assertEqual(result, [1, 2, 3, 4])


#import pickle

#favorite_color=[1,2,3,4]

#pickle.dump(favorite_color, open("save.p","wb"))

#favorite_color_unpickled=pickle.load(open("save.p","rb")
Esempio n. 10
0
 def test_original_list_same_as_unpickled_list(self):
     list_pickler(self.file, self.pickle_list)
     unpickled_list = unpickler(self.file)
     self.assertEqual(self.pickle_list, unpickled_list)
     print "Test complete..."
Esempio n. 11
0
	def test_unpickler_returns_same_list_as_original(self):
		pick_list = list_pickler(self.original_list, self.fil_name)
		self.assertEqual(self.original_list, unpickler(self.fil_name))
Esempio n. 12
0
 def test_original_and_unpickled_list_same(self):
     list_pickler(self.file, self.my_list)
     unpickled_list = unpickler(self.file)
     self.assertEqual(self.my_list, unpickled_list)
Esempio n. 13
0
    def test_pickled_then_unpickled_lists_are_equal(self):

        list_pickler(self.file_path, self.my_list)
        another_list = unpickler(self.file_path)
        self.assertEqual(self.my_list,another_list)
Esempio n. 14
0
	def test_pickled_list_equals_unpickled_list(self):
		list_pickler(self.file, self.my_list)
		unpickled_list = unpickler(self.file)
		self.assertEqual(self.my_list, unpickled_list)
Esempio n. 15
0
    def test_pickled_then_unpickled_lists_are_equal(self):

        list_pickler(self.file_path, self.my_list)
        another_list = unpickler(self.file_path)
        self.assertEqual(self.my_list, another_list)
Esempio n. 16
0
	def test_compare_lists(self):
		list_pickler(self.my_list,self.file)
		another_list = unpickler(self.file)
		self.assertEqual(self.my_list, another_list)
Esempio n. 17
0
 def setUp(self):
     self.list = ['a','b','c','d']
     list_pickler(self.list,'test_list.pkl')
Esempio n. 18
0
 def compare_pick_to_unpick_lists(self):
     list_pickler(self.file, self.test_list)
     unpicked_list = unpickler(self.file)
     self.assertEqual(self.test_list, unpicked_list)
Esempio n. 19
0
 def test_original_and_unpickled_list_same(self):
     list_pickler(self.my_list,self.file_name)
     unpickled_list = unpickler(self.file_name)
     unpickled_list = [5,4,3,2,1]
     self.assertEqual(self.my_list, unpickled_list)