mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Merged revisions 81459 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81459 | victor.stinner | 2010-05-22 04:11:07 +0200 (sam., 22 mai 2010) | 3 lines Issue #6268: Fix seek() method of codecs.open(), don't read the BOM twice after seek(0) ........
This commit is contained in:
		
							parent
							
								
									7126dbc867
								
							
						
					
					
						commit
						3fed0870a6
					
				
					 3 changed files with 28 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -1594,6 +1594,26 @@ def test_latin1(self):
 | 
			
		|||
                         b"\xe4\xeb\xef\xf6\xfc")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class BomTest(unittest.TestCase):
 | 
			
		||||
    def test_seek0(self):
 | 
			
		||||
        data = "1234567890"
 | 
			
		||||
        tests = ("utf-16",
 | 
			
		||||
                 "utf-16-le",
 | 
			
		||||
                 "utf-16-be",
 | 
			
		||||
                 "utf-32",
 | 
			
		||||
                 "utf-32-le",
 | 
			
		||||
                 "utf-32-be")
 | 
			
		||||
        for encoding in tests:
 | 
			
		||||
            with codecs.open('foo', 'w+', encoding=encoding) as f:
 | 
			
		||||
                # Check if the BOM is written only once
 | 
			
		||||
                f.write(data)
 | 
			
		||||
                f.write(data)
 | 
			
		||||
                f.seek(0)
 | 
			
		||||
                self.assertEquals(f.read(), data * 2)
 | 
			
		||||
                f.seek(0)
 | 
			
		||||
                self.assertEquals(f.read(), data * 2)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_main():
 | 
			
		||||
    support.run_unittest(
 | 
			
		||||
        UTF32Test,
 | 
			
		||||
| 
						 | 
				
			
			@ -1621,6 +1641,7 @@ def test_main():
 | 
			
		|||
        WithStmtTest,
 | 
			
		||||
        TypesTest,
 | 
			
		||||
        SurrogateEscapeTest,
 | 
			
		||||
        BomTest,
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue