Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py

Issue 2248653002: Revert of Fix pylint warnings in webkitpy/common/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Manual Revert (Patch Set 1 causes patch failure in read_checksum_from_png_unittest.py) Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # vim: set fileencoding=utf-8 : 1 # vim: set fileencoding=utf-8 :
2 # Copyright (C) 2010 Google Inc. All rights reserved. 2 # Copyright (C) 2010 Google Inc. All rights reserved.
3 # 3 #
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 if os.path.exists(sub_dir): 254 if os.path.exists(sub_dir):
255 os.rmdir(sub_dir) 255 os.rmdir(sub_dir)
256 256
257 def test_read_and_write_text_file(self): 257 def test_read_and_write_text_file(self):
258 fs = FileSystem() 258 fs = FileSystem()
259 text_path = None 259 text_path = None
260 260
261 unicode_text_string = u'\u016An\u012Dc\u014Dde\u033D' 261 unicode_text_string = u'\u016An\u012Dc\u014Dde\u033D'
262 try: 262 try:
263 text_path = tempfile.mktemp(prefix='tree_unittest_') 263 text_path = tempfile.mktemp(prefix='tree_unittest_')
264 out_file = fs.open_text_file_for_writing(text_path) 264 file = fs.open_text_file_for_writing(text_path)
265 out_file.write(unicode_text_string) 265 file.write(unicode_text_string)
266 out_file.close() 266 file.close()
267 267
268 in_file = fs.open_text_file_for_reading(text_path) 268 file = fs.open_text_file_for_reading(text_path)
269 read_text = in_file.read() 269 read_text = file.read()
270 in_file.close() 270 file.close()
271 271
272 self.assertEqual(read_text, unicode_text_string) 272 self.assertEqual(read_text, unicode_text_string)
273 finally: 273 finally:
274 if text_path and fs.isfile(text_path): 274 if text_path and fs.isfile(text_path):
275 os.remove(text_path) 275 os.remove(text_path)
276 276
277 def test_read_and_write_file(self): 277 def test_read_and_write_file(self):
278 fs = FileSystem() 278 fs = FileSystem()
279 text_path = None 279 text_path = None
280 binary_path = None 280 binary_path = None
(...skipping 24 matching lines...) Expand all
305 fs = FileSystem() 305 fs = FileSystem()
306 self.assertRaises(IOError, fs.read_text_file, self._missing_file) 306 self.assertRaises(IOError, fs.read_text_file, self._missing_file)
307 307
308 def test_remove_file_with_retry(self): 308 def test_remove_file_with_retry(self):
309 RealFileSystemTest._remove_failures = 2 309 RealFileSystemTest._remove_failures = 2
310 310
311 def remove_with_exception(filename): 311 def remove_with_exception(filename):
312 RealFileSystemTest._remove_failures -= 1 312 RealFileSystemTest._remove_failures -= 1
313 if RealFileSystemTest._remove_failures >= 0: 313 if RealFileSystemTest._remove_failures >= 0:
314 try: 314 try:
315 raise WindowsError # pylint: disable=undefined-variable 315 raise WindowsError
316 except NameError: 316 except NameError:
317 raise FileSystem._WindowsError 317 raise FileSystem._WindowsError
318 318
319 fs = FileSystem() 319 fs = FileSystem()
320 self.assertTrue(fs.remove('filename', remove_with_exception)) 320 self.assertTrue(fs.remove('filename', remove_with_exception))
321 self.assertEqual(-1, RealFileSystemTest._remove_failures) 321 self.assertEqual(-1, RealFileSystemTest._remove_failures)
322 322
323 def test_sep(self): 323 def test_sep(self):
324 fs = FileSystem() 324 fs = FileSystem()
325 325
326 self.assertEqual(fs.sep, os.sep) 326 self.assertEqual(fs.sep, os.sep)
327 self.assertEqual(fs.join("foo", "bar"), 327 self.assertEqual(fs.join("foo", "bar"),
328 os.path.join("foo", "bar")) 328 os.path.join("foo", "bar"))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698