OLD | NEW |
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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 # Clean up in case the test failed and we did create the | 252 # Clean up in case the test failed and we did create the |
253 # directory. | 253 # directory. |
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 hex_equivalent = '\xC5\xAA\x6E\xC4\xAD\x63\xC5\x8D\x64\x65\xCC\xBD' | |
263 try: | 262 try: |
264 text_path = tempfile.mktemp(prefix='tree_unittest_') | 263 text_path = tempfile.mktemp(prefix='tree_unittest_') |
265 file = fs.open_text_file_for_writing(text_path) | 264 file = fs.open_text_file_for_writing(text_path) |
266 file.write(unicode_text_string) | 265 file.write(unicode_text_string) |
267 file.close() | 266 file.close() |
268 | 267 |
269 file = fs.open_text_file_for_reading(text_path) | 268 file = fs.open_text_file_for_reading(text_path) |
270 read_text = file.read() | 269 read_text = file.read() |
271 file.close() | 270 file.close() |
272 | 271 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 fs = FileSystem() | 319 fs = FileSystem() |
321 self.assertTrue(fs.remove('filename', remove_with_exception)) | 320 self.assertTrue(fs.remove('filename', remove_with_exception)) |
322 self.assertEqual(-1, RealFileSystemTest._remove_failures) | 321 self.assertEqual(-1, RealFileSystemTest._remove_failures) |
323 | 322 |
324 def test_sep(self): | 323 def test_sep(self): |
325 fs = FileSystem() | 324 fs = FileSystem() |
326 | 325 |
327 self.assertEqual(fs.sep, os.sep) | 326 self.assertEqual(fs.sep, os.sep) |
328 self.assertEqual(fs.join("foo", "bar"), | 327 self.assertEqual(fs.join("foo", "bar"), |
329 os.path.join("foo", "bar")) | 328 os.path.join("foo", "bar")) |
OLD | NEW |