Example #1
0
 def test_get_checksum_from_string(self):
     test = utils.random_ascii()
     md = hashlib.md5()
     md.update(test)
     expected = md.hexdigest()
     received = utils.get_checksum(test)
     self.assertEqual(expected, received)
Example #2
0
 def test_get_checksum_from_string(self):
     test = utils.random_ascii()
     md = hashlib.md5()
     md.update(test)
     expected = md.hexdigest()
     received = utils.get_checksum(test)
     self.assertEqual(expected, received)
Example #3
0
 def test_get_checksum_from_binary(self):
     test = fakes.get_png_content()
     md = hashlib.md5()
     enc = "utf8"
     md.update(test)
     expected = md.hexdigest()
     received = utils.get_checksum(test)
     self.assertEqual(expected, received)
Example #4
0
 def test_get_checksum_from_unicode_alt_encoding(self):
     test = u"some ñøñåßçîî text"
     md = hashlib.md5()
     enc = "Windows-1252"
     md.update(test.encode(enc))
     expected = md.hexdigest()
     received = utils.get_checksum(test, enc)
     self.assertEqual(expected, received)
Example #5
0
 def test_get_checksum_from_unicode(self):
     test = utils.random_unicode()
     md = hashlib.md5()
     enc = "utf8"
     md.update(test.encode(enc))
     expected = md.hexdigest()
     received = utils.get_checksum(test)
     self.assertEqual(expected, received)
Example #6
0
 def test_get_checksum_from_binary(self):
     test = fakes.get_png_content()
     md = hashlib.md5()
     enc = "utf8"
     md.update(test)
     expected = md.hexdigest()
     received = utils.get_checksum(test)
     self.assertEqual(expected, received)
Example #7
0
 def test_get_checksum_from_unicode_alt_encoding(self):
     test = u"some ñøñåßçîî text"
     md = hashlib.md5()
     enc = "Windows-1252"
     md.update(test.encode(enc))
     expected = md.hexdigest()
     received = utils.get_checksum(test, enc)
     self.assertEqual(expected, received)
Example #8
0
 def test_get_checksum_from_unicode(self):
     test = utils.random_unicode()
     md = hashlib.md5()
     enc = "utf8"
     md.update(test.encode(enc))
     expected = md.hexdigest()
     received = utils.get_checksum(test)
     self.assertEqual(expected, received)
Example #9
0
 def test_get_checksum_from_file(self):
     test = "some random text"
     md = hashlib.md5()
     md.update(test)
     expected = md.hexdigest()
     with utils.SelfDeletingTempfile() as tmp:
         with open(tmp, "w") as testfile:
             testfile.write(test)
         with open(tmp, "r") as testfile:
             received = utils.get_checksum(testfile)
     self.assertEqual(expected, received)
Example #10
0
 def test_get_checksum_from_file(self):
     test = "some random text"
     md = hashlib.md5()
     md.update(test)
     expected = md.hexdigest()
     with utils.SelfDeletingTempfile() as tmp:
         with open(tmp, "w") as testfile:
             testfile.write(test)
         with open(tmp, "r") as testfile:
             received = utils.get_checksum(testfile)
     self.assertEqual(expected, received)