Exemplo n.º 1
0
    def test_compute_checksums(self):
        open(self.file_path, "w").write("hello\n")

        res_origin = {}
        for name in ("md5", "sha1", "sha256", "sha512"):
            m = hashlib.new(name)
            m.update(open(self.file_path, "rb").read())
            res_origin[name] = m.hexdigest()

        wrap = FileWrapper(self.file_path)
        res = wrap.compute_checksums(["md5", "sha1", "sha256", "sha512"])
        self.assertEqual(res_origin, res)
Exemplo n.º 2
0
    def test_compute_checksums(self):
        open(self.file_path, "w").write("hello\n")

        res_origin = {}
        for name in ("md5", "sha1", "sha256", "sha512"):
            m = hashlib.new(name)
            m.update(open(self.file_path, "rb").read())
            res_origin[name] = m.hexdigest()

        wrap = FileWrapper(self.file_path)
        res = wrap.compute_checksums(["md5", "sha1", "sha256", "sha512"])
        self.assertEqual(res_origin, res)
Exemplo n.º 3
0
 def test_pickle(self):
     self.test_file_name_property()
     name = "file"
     file1 = os.path.join(self.tmp_dir, name)
     wrap = FileWrapper(file1)
     pickled_data = pickle.dumps(wrap)
     wrap2 = pickle.loads(pickled_data)
     print(wrap2.file_path)
Exemplo n.º 4
0
 def test_file_name_property(self):
     open(self.file_path, "w").write("hello\n")
     wrap = FileWrapper(self.file_path)
     self.assertEqual(wrap.file_path, self.file_path)
     self.assertEqual(wrap.file_name, os.path.basename(self.file_path))