summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/html_module_unittest.py
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/html_module_unittest.py')
-rw-r--r--chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/html_module_unittest.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/html_module_unittest.py b/chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/html_module_unittest.py
index e8438f4db23..b6d9f93a5ee 100644
--- a/chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/html_module_unittest.py
+++ b/chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/html_module_unittest.py
@@ -5,6 +5,7 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
+from io import BytesIO
import os
import unittest
@@ -18,6 +19,8 @@ from py_vulcanize import project as project_module
from py_vulcanize import resource
from py_vulcanize import resource_loader as resource_loader
import six
+if six.PY3:
+ import functools
class ResourceWithFakeContents(resource.Resource):
@@ -56,7 +59,10 @@ class FakeLoader(object):
return None
# Sort by length. Longest match wins.
- candidate_paths.sort(lambda x, y: len(x) - len(y))
+ if six.PY3:
+ sorted(candidate_paths, key=functools.cmp_to_key(lambda x, y: len(x) - len(y)), reverse=True)
+ else:
+ candidate_paths.sort(lambda x, y: len(x) - len(y))
longest_candidate = candidate_paths[-1]
return ResourceWithFakeContents(
@@ -300,7 +306,7 @@ console.log('/raw/raw_script.js was written');
}
</style>
"""
- file_contents[os.path.normpath('/tmp/a/something.jpg')] = 'jpgdata'
+ file_contents[os.path.normpath('/tmp/a/something.jpg')] = b'jpgdata'
with fake_fs.FakeFS(file_contents):
project = project_module.Project([
os.path.normpath('/py_vulcanize/'), os.path.normpath('/tmp/')])