Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: tests/tools.py

Issue 29501558: Issue 5383 - Add tests for the Chrome and Firefox packagers (Closed)
Patch Set: Addressing pep8 error from last review Created Aug. 11, 2017, 12:12 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/tools.py
diff --git a/tests/tools.py b/tests/tools.py
new file mode 100644
index 0000000000000000000000000000000000000000..28a432b8ed62d96de2437a63dbfae81ed3f496e8
--- /dev/null
+++ b/tests/tools.py
@@ -0,0 +1,26 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+import os
+import shutil
+
+
+def get_leafs_string(tree):
+ """Recursively builds a string, representing the path to all leaf-nodes"""
+ root_str = '{}|{}|{}'.format(tree.tag, tree.tail, tree.text).strip()
+ result = []
+
+ if len(tree) > 0:
+ for subtree in tree:
+ for leaf in get_leafs_string(subtree):
+ result.append('{}__{}'.format(root_str, leaf))
+ else:
+ result.append(root_str)
+ return result
+
+
+def copy_metadata(filename, tmpdir):
+ path = os.path.join(os.path.dirname(__file__), filename)
+ destination = str(tmpdir.join(filename))
+ shutil.copy(path, destination)

Powered by Google App Engine
This is Rietveld