예제 #1
0
 def test_should_keep_fileending_of_target_file(self):
     tempfile.mkstemp = self.old_mkstemp
     with imagemagick.temp_file(self.target) as result:
         self.assertEquals(
             self.target.split('.')[-1],
             result.split('.')[-1])
         open(result, 'w').write("hello")
예제 #2
0
 def test_should_overwrite_target_file_if_already_exists(self):
     open(self.target,'w').write("good bye")
     
     with imagemagick.temp_file(self.target) as result:
         open(result, 'w').write("hello")
     
     self.assertEquals("hello", open(self.target, 'r').read())
예제 #3
0
    def test_should_overwrite_target_file_if_already_exists(self):
        open(self.target, 'w').write("good bye")

        with imagemagick.temp_file(self.target) as result:
            open(result, 'w').write("hello")

        self.assertEquals("hello", open(self.target, 'r').read())
예제 #4
0
 def test_should_remove_tempfile_if_failing(self):
     
     try:
         with imagemagick.temp_file(self.target) as result:
             open(result, 'w').write("hello")
             raise Exception
             
     except Exception:
         self.assertFalse(os.path.isfile(self.temp_file))
예제 #5
0
    def test_should_remove_tempfile_if_failing(self):

        try:
            with imagemagick.temp_file(self.target) as result:
                open(result, 'w').write("hello")
                raise Exception

        except Exception:
            self.assertFalse(os.path.isfile(self.temp_file))
예제 #6
0
 def test_should_keep_fileending_of_target_file(self):
     tempfile.mkstemp = self.old_mkstemp
     with imagemagick.temp_file(self.target) as result:
         self.assertEquals(self.target.split('.')[-1], result.split('.')[-1])
         open(result, 'w').write("hello")
예제 #7
0
 def test_should_remove_tempfile_after_done(self):
     with imagemagick.temp_file(self.target) as result:
         open(result, 'w').write("hello")
                     
     self.assertFalse(os.path.isfile(self.temp_file))
예제 #8
0
 def test_should_replace_target_with_temp_file(self): 
     with imagemagick.temp_file(self.target) as result:
         open(result, 'w').write("hello")
     
     self.assertEquals("hello", open(self.target, 'r').read())
예제 #9
0
 def test_should_work_on_temp_file(self): 
     with imagemagick.temp_file(self.target) as result:
         open(result, 'w').write("hello")
         self.assertEquals(self.temp_file, result)
         self.assertTrue(os.path.isfile(self.temp_file))
예제 #10
0
    def test_should_remove_tempfile_after_done(self):
        with imagemagick.temp_file(self.target) as result:
            open(result, 'w').write("hello")

        self.assertFalse(os.path.isfile(self.temp_file))
예제 #11
0
    def test_should_replace_target_with_temp_file(self):
        with imagemagick.temp_file(self.target) as result:
            open(result, 'w').write("hello")

        self.assertEquals("hello", open(self.target, 'r').read())
예제 #12
0
 def test_should_work_on_temp_file(self):
     with imagemagick.temp_file(self.target) as result:
         open(result, 'w').write("hello")
         self.assertEquals(self.temp_file, result)
         self.assertTrue(os.path.isfile(self.temp_file))