Exemplo n.º 1
0
 def test_lazy_read(self):
     with make_named_files() as temp_file:
         with open_exception(temp_file.name):
             temp_file.write('test')
             temp_file.flush()
             
             handler = self.handler(temp_file.name, 'file') #No exception yet
             self.assertRaises(TestException, getattr, handler, 'content') #Read when requested
Exemplo n.º 2
0
    def test_lazy_read(self):
        with make_named_files() as temp_file:
            with open_exception(temp_file.name):
                temp_file.write('test')
                temp_file.flush()

                handler = self.handler(temp_file.name,
                                       'file')  #No exception yet
                self.assertRaises(TestException, getattr, handler,
                                  'content')  #Read when requested
Exemplo n.º 3
0
 def test_hash(self):
     import hashlib
     import os.path
     handler = self.handler('test', 'content')
     self.assertEqual(hashlib.sha1('test').hexdigest(), handler.hash)
     
     with make_named_files() as temp_file:
         with open_exception(temp_file.name): #Don't allow it to open the file for the hash
             temp_file.write('test')
             temp_file.flush()
             
             handler = self.handler(temp_file.name, 'file')
             self.assertEqual(hashlib.sha1(str(os.path.getmtime(temp_file.name))).hexdigest(), handler.hash)
Exemplo n.º 4
0
    def test_hash(self):
        import hashlib
        import os.path
        handler = self.handler('test', 'content')
        self.assertEqual(hashlib.sha1('test').hexdigest(), handler.hash)

        with make_named_files() as temp_file:
            with open_exception(
                    temp_file.name
            ):  #Don't allow it to open the file for the hash
                temp_file.write('test')
                temp_file.flush()

                handler = self.handler(temp_file.name, 'file')
                self.assertEqual(
                    hashlib.sha1(str(os.path.getmtime(
                        temp_file.name))).hexdigest(), handler.hash)