Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 # This Source Code Form is subject to the terms of the Mozilla Public | 1 # This Source Code Form is subject to the terms of the Mozilla Public |
2 # License, v. 2.0. If a copy of the MPL was not distributed with this | 2 # License, v. 2.0. If a copy of the MPL was not distributed with this |
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
4 | 4 |
5 import difflib | |
6 import json | |
5 import os | 7 import os |
8 import re | |
6 import shutil | 9 import shutil |
7 import zipfile | 10 import zipfile |
8 import json | 11 from xml.etree import ElementTree |
9 import re | |
10 from struct import unpack | 12 from struct import unpack |
11 import difflib | |
12 | 13 |
13 import pytest | 14 import pytest |
15 from Crypto.Signature import PKCS1_v1_5 | |
16 from Crypto.PublicKey import RSA | |
14 from Crypto.Hash import SHA | 17 from Crypto.Hash import SHA |
15 from Crypto.PublicKey import RSA | |
16 from Crypto.Signature import PKCS1_v1_5 | |
17 from xml.etree import ElementTree | |
Vasily Kuznetsov
2017/10/21 17:41:10
The imports should be sorted+grouped in the follow
tlucas
2017/10/22 11:19:13
Done.
| |
18 | 18 |
19 from buildtools import packager | 19 from buildtools import packager |
20 from buildtools.packagerChrome import defaultLocale | 20 from buildtools.packagerChrome import defaultLocale |
21 from buildtools.build import processArgs | 21 from buildtools.build import processArgs |
22 | 22 |
23 LOCALES_MODULE = { | 23 LOCALES_MODULE = { |
24 'test.Foobar': { | 24 'test.Foobar': { |
25 'message': 'Ensuring dict-copy from modules for $domain$', | 25 'message': 'Ensuring dict-copy from modules for $domain$', |
26 'description': 'test description', | 26 'description': 'test description', |
27 'placeholders': {'content': '$1', 'example': 'www.adblockplus.org'} | 27 'placeholders': {'content': '$1', 'example': 'www.adblockplus.org'} |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 files['ext/c.js'] = 'var this_is_c;' | 233 files['ext/c.js'] = 'var this_is_c;' |
234 | 234 |
235 tmpdir.mkdir('lib').join('b.js').write(files['lib/b.js']) | 235 tmpdir.mkdir('lib').join('b.js').write(files['lib/b.js']) |
236 ext_dir = tmpdir.mkdir('ext') | 236 ext_dir = tmpdir.mkdir('ext') |
237 ext_dir.join('a.js').write(files['ext/a.js']) | 237 ext_dir.join('a.js').write(files['ext/a.js']) |
238 ext_dir.join('c.js').write(files['ext/c.js']) | 238 ext_dir.join('c.js').write(files['ext/c.js']) |
239 | 239 |
240 return files | 240 return files |
241 | 241 |
242 | 242 |
243 def comparable_xml(xml): | 243 def comparable_xml(xml): |
Vasily Kuznetsov
2017/10/21 17:41:11
I suppose it doesn't matter for the purposes of th
tlucas
2017/10/22 11:19:12
I adjusted the docstring to clarify this limitatio
| |
244 """Create a nonambiguous representation of a given XML tree.""" | 244 """Create a nonambiguous representation of a given XML tree. |
245 | |
246 Note that this function is not safe against ambiguous tags | |
247 containing differently distributed children, e.g.: | |
248 | |
249 '<a><b><c/></b><b><d/></b></a>' | |
250 vs. | |
251 '<a><b/><b><c/><d/></b></a>' | |
252 | |
253 This is irrelevant for comparing the XML used by the tests of this | |
254 module. | |
255 """ | |
245 def get_leafs_string(tree): | 256 def get_leafs_string(tree): |
246 """Recursively build a string representing all xml leaf-nodes.""" | 257 """Recursively build a string representing all xml leaf-nodes.""" |
247 root_str = '{}|{}|{}'.format(tree.tag, tree.tail, tree.text).strip() | 258 root_str = '{}|{}|{}'.format(tree.tag, tree.tail, tree.text).strip() |
248 result = [] | 259 result = [] |
249 | 260 |
250 if len(tree) > 0: | 261 if len(tree) > 0: |
251 for subtree in tree: | 262 for subtree in tree: |
252 for leaf in get_leafs_string(subtree): | 263 for leaf in get_leafs_string(subtree): |
253 result.append('{}__{}'.format(root_str, leaf)) | 264 result.append('{}__{}'.format(root_str, leaf)) |
254 for k, v in tree.attrib.items(): | 265 for k, v in tree.attrib.items(): |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
465 expected = os.path.join( | 476 expected = os.path.join( |
466 os.path.dirname(__file__), | 477 os.path.dirname(__file__), |
467 'expecteddata', | 478 'expecteddata', |
468 filename.format(name, ext), | 479 filename.format(name, ext), |
469 ) | 480 ) |
470 | 481 |
471 assert_manifest_content( | 482 assert_manifest_content( |
472 package.read(os.path.join(folder, '{}.{}'.format(name, ext))), | 483 package.read(os.path.join(folder, '{}.{}'.format(name, ext))), |
473 expected, | 484 expected, |
474 ) | 485 ) |
LEFT | RIGHT |