示例#1
0
 def test_pickle_Pic_object(self):
     # make sure pickling and unpickling is working.
     from Pic import Pic
     # Pic object needs a "start_response" object. We'll fake it.
     import wsgiref.simple_server
     this_handler = wsgiref.simple_server.ServerHandler(sys.stdin,sys.stdout,sys.stderr, os.environ)
     pic_path = os.path.join(os.pardir,'test_album','boys','1370366193_1ace76e049_b_d.jpg')
     # Try to pickle
     this_Pic = Pic(this_handler.start_response, pic_path)
     self.assertTrue('1370366193_1ace76e049_b_d.jpg' in this_Pic.getFileName())
     # Now unpickle
     new_Pic = Pic.loadPickledVersion(this_handler.start_response,pic_path)
     self.assertTrue('1370366193_1ace76e049_b_d.jpg' in new_Pic.getFileName())
     # clean up our pickly mess
     os.remove(this_Pic.getPicklePath(pic_path))
示例#2
0
文件: test_pic.py 项目: GitRay/pix2
    def test_pickle_path(self):
        # some pickle paths were too long for the filesystem
        from Pic import Pic
        import Setup

        long_file_name = os.path.abspath(
            os.path.join(
                os.pardir,
                "test_album",
                "other",
                "Stella, on back - Q.A.C. Speech Day - June 14, 1975 L. to R. Two male teachers, Mrs. Elhhetih, Mrs. Lacey, Mde De Nehludoff, Y.T., Mrs. Bisade, Mrs. Abdullehi - principal - and Mrs. Abbe Kyari - wife of the then Governor of Keduna State.tif",
            )
        )
        short_file_name = Pic.getPicklePath(long_file_name)
        self.assertTrue(len(short_file_name) < Setup.f_namemax)