summaryrefslogtreecommitdiff
path: root/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2013-09-13 12:51:20 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-19 20:50:05 +0200
commitd441d6f39bb846989d95bcf5caf387b42414718d (patch)
treee367e64a75991c554930278175d403c072de6bb8 /Tools/Scripts/webkitpy/common/system/filesystem_unittest.py
parent0060b2994c07842f4c59de64b5e3e430525c4b90 (diff)
downloadqtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit. Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Tools/Scripts/webkitpy/common/system/filesystem_unittest.py')
-rw-r--r--Tools/Scripts/webkitpy/common/system/filesystem_unittest.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py b/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py
index d656b2580..cd4ad6e4a 100644
--- a/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py
+++ b/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py
@@ -35,7 +35,7 @@ import os
import stat
import sys
import tempfile
-import unittest
+import unittest2 as unittest
from filesystem import FileSystem
@@ -209,6 +209,8 @@ class RealFileSystemTest(unittest.TestCase, GenericFileSystemTests):
unicode_text_string = u'\u016An\u012Dc\u014Dde\u033D'
hex_equivalent = '\xC5\xAA\x6E\xC4\xAD\x63\xC5\x8D\x64\x65\xCC\xBD'
+ malformed_text_hex = '\x4D\x69\x63\x72\x6F\x73\x6F\x66\x74\xAE\x20\x56\x69\x73\x75\x61\x6C\x20\x53\x74\x75\x64\x69\x6F\xAE\x20\x32\x30\x31\x30\x0D\x0A'
+ malformed_ignored_text_hex = '\x4D\x69\x63\x72\x6F\x73\x6F\x66\x74\x20\x56\x69\x73\x75\x61\x6C\x20\x53\x74\x75\x64\x69\x6F\x20\x32\x30\x31\x30\x0D\x0A'
try:
text_path = tempfile.mktemp(prefix='tree_unittest_')
binary_path = tempfile.mktemp(prefix='tree_unittest_')
@@ -219,6 +221,12 @@ class RealFileSystemTest(unittest.TestCase, GenericFileSystemTests):
fs.write_binary_file(binary_path, hex_equivalent)
text_contents = fs.read_text_file(binary_path)
self.assertEqual(text_contents, unicode_text_string)
+
+ self.assertRaises(ValueError, fs.write_text_file, binary_path, malformed_text_hex)
+ fs.write_binary_file(binary_path, malformed_text_hex)
+ self.assertRaises(ValueError, fs.read_text_file, binary_path)
+ text_contents = fs.read_binary_file(binary_path).decode('utf8', 'ignore')
+ self.assertEquals(text_contents, malformed_ignored_text_hex)
finally:
if text_path and fs.isfile(text_path):
os.remove(text_path)
@@ -254,7 +262,3 @@ class RealFileSystemTest(unittest.TestCase, GenericFileSystemTests):
self.assertEqual(fs.sep, os.sep)
self.assertEqual(fs.join("foo", "bar"),
os.path.join("foo", "bar"))
-
-
-if __name__ == '__main__':
- unittest.main()