aboutsummaryrefslogtreecommitdiff
path: root/tests/docx/document_matchers.py
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2017-02-19 21:35:42 +0000
committerMichael Williamson <mike@zwobble.org>2017-02-19 21:35:42 +0000
commit74bbea738776bad4ddbcc1af19a44114e1defb07 (patch)
tree50b8d9e9887f2772b989b97fd0d00ec190ad6941 /tests/docx/document_matchers.py
parentc8f835e3ed5d464f7c6bf15d77dce40918afd11a (diff)
Handle hyperlinks created with complex fields
Diffstat (limited to 'tests/docx/document_matchers.py')
-rw-r--r--tests/docx/document_matchers.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/docx/document_matchers.py b/tests/docx/document_matchers.py
new file mode 100644
index 0000000..dd2276d
--- /dev/null
+++ b/tests/docx/document_matchers.py
@@ -0,0 +1,28 @@
+from precisely import all_of, has_attrs, instance_of
+
+from mammoth import documents
+
+
+def create_element_matcher(element_type):
+ def matcher(**kwargs):
+ return all_of(
+ instance_of(element_type),
+ has_attrs(**kwargs),
+ )
+
+ return matcher
+
+
+is_paragraph = create_element_matcher(documents.Paragraph)
+is_run = create_element_matcher(documents.Run)
+is_hyperlink = create_element_matcher(documents.Hyperlink)
+
+
+is_empty_run = is_run(children=[])
+
+
+def is_text(value):
+ return all_of(
+ instance_of(documents.Text),
+ has_attrs(value=value),
+ )