mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	Merged revisions 72979 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r72979 | philip.jenvey | 2009-05-27 22:58:44 -0700 (Wed, 27 May 2009) | 2 lines explicitly close files ........
This commit is contained in:
		
							parent
							
								
									3d2dc35a28
								
							
						
					
					
						commit
						a27c5bd2bd
					
				
					 3 changed files with 29 additions and 30 deletions
				
			
		|  | @ -135,14 +135,13 @@ def test_html_diff(self): | |||
|              k.make_table(f3.splitlines(True),t3.splitlines(True)), | ||||
|              ]) | ||||
|         actual = full.replace('</body>','\n%s\n</body>' % tables) | ||||
|         # temporarily uncomment next three lines to baseline this test | ||||
|         #f = open('test_difflib_expect.html','w') | ||||
|         #f.write(actual) | ||||
|         #f.close() | ||||
|         expect = open(findfile('test_difflib_expect.html')).read() | ||||
| 
 | ||||
|         # temporarily uncomment next two lines to baseline this test | ||||
|         #with open('test_difflib_expect.html','w') as fp: | ||||
|         #    fp.write(actual) | ||||
| 
 | ||||
|         self.assertEqual(actual,expect) | ||||
|         with open(findfile('test_difflib_expect.html')) as fp: | ||||
|             self.assertEqual(actual, fp.read()) | ||||
| 
 | ||||
|     def test_recursion_limit(self): | ||||
|         # Check if the problem described in patch #1413711 exists. | ||||
|  |  | |||
|  | @ -175,7 +175,8 @@ class GetSourceBase(unittest.TestCase): | |||
|     def __init__(self, *args, **kwargs): | ||||
|         unittest.TestCase.__init__(self, *args, **kwargs) | ||||
| 
 | ||||
|         self.source = open(inspect.getsourcefile(self.fodderFile)).read() | ||||
|         with open(inspect.getsourcefile(self.fodderFile)) as fp: | ||||
|             self.source = fp.read() | ||||
| 
 | ||||
|     def sourcerange(self, top, bottom): | ||||
|         lines = self.source.split("\n") | ||||
|  |  | |||
|  | @ -37,12 +37,11 @@ class TestGenericUnivNewlines(unittest.TestCase): | |||
|     WRITEMODE = 'wb' | ||||
| 
 | ||||
|     def setUp(self): | ||||
|         fp = self.open(support.TESTFN, self.WRITEMODE) | ||||
|         data = self.DATA | ||||
|         if "b" in self.WRITEMODE: | ||||
|             data = data.encode("ascii") | ||||
|         with self.open(support.TESTFN, self.WRITEMODE) as fp: | ||||
|             fp.write(data) | ||||
|         fp.close() | ||||
| 
 | ||||
|     def tearDown(self): | ||||
|         try: | ||||
|  | @ -51,19 +50,19 @@ def tearDown(self): | |||
|             pass | ||||
| 
 | ||||
|     def test_read(self): | ||||
|         fp = self.open(support.TESTFN, self.READMODE) | ||||
|         with self.open(support.TESTFN, self.READMODE) as fp: | ||||
|             data = fp.read() | ||||
|         self.assertEqual(data, DATA_LF) | ||||
|         self.assertEqual(repr(fp.newlines), repr(self.NEWLINE)) | ||||
| 
 | ||||
|     def test_readlines(self): | ||||
|         fp = self.open(support.TESTFN, self.READMODE) | ||||
|         with self.open(support.TESTFN, self.READMODE) as fp: | ||||
|             data = fp.readlines() | ||||
|         self.assertEqual(data, DATA_SPLIT) | ||||
|         self.assertEqual(repr(fp.newlines), repr(self.NEWLINE)) | ||||
| 
 | ||||
|     def test_readline(self): | ||||
|         fp = self.open(support.TESTFN, self.READMODE) | ||||
|         with self.open(support.TESTFN, self.READMODE) as fp: | ||||
|             data = [] | ||||
|             d = fp.readline() | ||||
|             while d: | ||||
|  | @ -73,7 +72,7 @@ def test_readline(self): | |||
|         self.assertEqual(repr(fp.newlines), repr(self.NEWLINE)) | ||||
| 
 | ||||
|     def test_seek(self): | ||||
|         fp = self.open(support.TESTFN, self.READMODE) | ||||
|         with self.open(support.TESTFN, self.READMODE) as fp: | ||||
|             fp.readline() | ||||
|             pos = fp.tell() | ||||
|             data = fp.readlines() | ||||
|  | @ -96,7 +95,7 @@ class TestCRLFNewlines(TestGenericUnivNewlines): | |||
|     DATA = DATA_CRLF | ||||
| 
 | ||||
|     def test_tell(self): | ||||
|         fp = self.open(support.TESTFN, self.READMODE) | ||||
|         with self.open(support.TESTFN, self.READMODE) as fp: | ||||
|             self.assertEqual(repr(fp.newlines), repr(None)) | ||||
|             data = fp.readline() | ||||
|             pos = fp.tell() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Philip Jenvey
						Philip Jenvey