| BBB |
-
+
| CCC |
DDD |
@@ -265,7 +230,6 @@ def test_nested_table_rowspan():
-
''')
@@ -278,9 +242,8 @@ def test_nested_tables():
)
actual_html = convert(file_path)
# Find out why br tag is there.
- assert_html_equal(actual_html, '''
-
-
+ assert_html_equal(actual_html, BASE_HTML % '''
+
| AAA |
BBB |
@@ -288,7 +251,7 @@ def test_nested_tables():
| CCC |
-
+
| DDD |
EEE |
@@ -301,7 +264,6 @@ def test_nested_tables():
-
''')
@@ -313,12 +275,11 @@ def test_list_in_table():
'list_in_table.docx',
)
actual_html = convert(file_path)
- assert_html_equal(actual_html, '''
-
-
+ assert_html_equal(actual_html, BASE_HTML % '''
+
-
+
- AAA
- BBB
- CCC
@@ -326,7 +287,6 @@ def test_list_in_table():
|
-
''')
@@ -338,12 +298,11 @@ def test_tables_in_lists():
'tables_in_lists.docx',
)
actual_html = convert(file_path)
- assert_html_equal(actual_html, '''
-
-
+ assert_html_equal(actual_html, BASE_HTML % '''
+
- AAA
- BBB
-
+
| CCC |
DDD |
@@ -356,7 +315,6 @@ def test_tables_in_lists():
- GGG
-
''')
@@ -368,8 +326,8 @@ def test_track_changes_on():
'track_changes_on.docx',
)
actual_html = convert(file_path)
- assert_html_equal(actual_html, '''
- This was some content.
+ assert_html_equal(actual_html, BASE_HTML % '''
+ This was some content.
''')
@@ -381,8 +339,7 @@ def test_headers():
'headers.docx',
)
actual_html = convert(file_path)
- assert_html_equal(actual_html, '''
-
+ assert_html_equal(actual_html, BASE_HTML % '''
This is an H1
This is an H2
This is an H3
@@ -393,7 +350,6 @@ def test_headers():
This is an H8
This is an H9
This is an H10
-
''')
@@ -420,8 +376,8 @@ def test_split_headers():
new_file_path, _ = _copy_file_to_tmp_dir(file_path, filename)
actual_html = convert(new_file_path)
- assert_html_equal(actual_html, '''
- AAABBB CCC
+ assert_html_equal(actual_html, BASE_HTML % '''
+ AAABBB CCC
''')
@@ -440,10 +396,8 @@ def test_has_image():
actual_html = convert(new_file_path)
# Ignore height, width for now.
- assert_html_equal(actual_html, '''
-
+ assert_html_equal(actual_html, BASE_HTML % '''
AAA
-
''')
@@ -457,10 +411,8 @@ def test_local_dpi():
)
new_file_path, dp = _copy_file_to_tmp_dir(file_path, filename)
actual_html = convert(new_file_path)
- assert_html_equal(actual_html, '''
-
+ assert_html_equal(actual_html, BASE_HTML % '''

-
''')
@@ -481,45 +433,11 @@ def test_has_image_using_image_handler():
def image_handler(*args, **kwargs):
return 'test'
actual_html = convert(new_file_path)
- assert_html_equal(actual_html, '''
-
+ assert_html_equal(actual_html, BASE_HTML % '''
AAA
-
''')
-#def test_attachment_is_tiff():
-# filename = 'attachment_is_tiff.docx'
-# file_path = path.join(
-# path.abspath(path.dirname(__file__)),
-# '..',
-# 'fixtures',
-# 'attachment_is_tiff.docx',
-# )
-# # preserve_images must be true in order for the image to not be removed.
-# # This is handled in build_import, however here we need to manually set it
-# # to True.
-# new_file_path, _ = _copy_file_to_tmp_dir(file_path, filename)
-#
-# # First open the file and verify that the image attachment is a tiff.
-# try:
-# zf = ZipFile(new_file_path)
-# # Get the document data.
-# _, meta_data = _get_document_data(zf)
-# finally:
-# zf.close()
-# # Find the path to the image.
-# image_file = None
-# for file_path in meta_data.relationship_dict.values():
-# if file_path.endswith('.gif'):
-# image_file = file_path
-# assert image_file is not None
-# with open(image_file) as f:
-# magic_number = f.read()[:4]
-# # Make sure the image is actually a gif.
-# assert magic_number == 'GIF8'
-
-
def test_headers_with_full_line_styles():
raise SkipTest('This test is not yet passing')
# Show that if a natural header is completely bold/italics that
@@ -531,12 +449,10 @@ def test_headers_with_full_line_styles():
'headers_with_full_line_styles.docx',
)
actual_html = convert(file_path)
- assert_html_equal(actual_html, '''
-
+ assert_html_equal(actual_html, BASE_HTML % '''
AAA
BBB
CCC
-
''')
@@ -551,17 +467,16 @@ def test_convert_p_to_h():
'convert_p_to_h.docx',
)
actual_html = convert(file_path)
- assert_html_equal(actual_html, '''
-
+ assert_html_equal(actual_html, BASE_HTML % '''
AAA
BBB
CCC
-
+
- DDD
- EEE
- FFF
-
+
| GGG |
HHH |
@@ -571,43 +486,9 @@ def test_convert_p_to_h():
JJJ |
-
''')
-#def test_bigger_font_size_to_header():
-# # Show when it is appropriate to convert p tags to h tags based on font
-# # size.
-# if not DETECT_FONT_SIZE:
-# raise SkipTest('Font size detection is disabled.')
-# file_path = path.join(
-# path.abspath(path.dirname(__file__)),
-# '..',
-# 'fixtures',
-# 'bigger_font_size_to_header.docx',
-# )
-# actual_html = convert(file_path)
-# assert_html_equal(actual_html, '''
-#
-# Paragraphs:
-# Header
-# paragraph 1
-# Lists:
-#
-# - bigger
-# - smaller
-#
-# Tables:
-#
-#
-# | bigger |
-# smaller |
-#
-#
-#
-# ''')
-
-
def test_fake_headings_by_length():
raise SkipTest('This test is not yet passing')
# Show that converting p tags to h tags has a length limit. If the p tag is
@@ -620,14 +501,12 @@ def test_fake_headings_by_length():
'fake_headings_by_length.docx',
)
actual_html = convert(file_path)
- assert_html_equal(actual_html, '''
-
+ assert_html_equal(actual_html, BASE_HTML % '''
Heading.
Still a heading.
This is not a heading because it is too many words.
-
''')
@@ -642,15 +521,14 @@ def test_shift_enter():
# Test just the convert without clean_html to make sure the first
# break tag is present.
actual_html = convert(file_path)
- assert_html_equal(actual_html, '''
-
+ assert_html_equal(actual_html, BASE_HTML % '''
AAA BBB
CCC
-
+
- DDD
EEE
- FFF
-
+
GGG HHH |
III JJJ |
@@ -660,7 +538,6 @@ def test_shift_enter():
LLL |
-
''')
@@ -672,17 +549,16 @@ def test_lists_with_styles():
'lists_with_styles.docx',
)
actual_html = convert(file_path)
- assert_html_equal(actual_html, '''
-
-
+ assert_html_equal(actual_html, BASE_HTML % '''
+
- AAA
- BBB
-
+
- CCC
- DDD
-
+
- EEE
-
+
- FFF
@@ -691,7 +567,6 @@ def test_lists_with_styles():
-
''')
@@ -706,25 +581,23 @@ def test_list_to_header():
actual_html = convert(file_path)
# It should be noted that list item `GGG` is upper roman in the word
# document to show that only top level upper romans get converted.
- assert_html_equal(actual_html, '''
-
+ assert_html_equal(actual_html, BASE_HTML % '''
AAA
-
+
- BBB
CCC
-
+
- DDD
EEE
-
+
- FFF
-
+
- GGG
-
''')
@@ -736,11 +609,10 @@ def test_has_title():
'has_title.docx',
)
actual_html = convert(file_path)
- assert_html_equal(
- actual_html,
- '''Title
- Text ''',
- )
+ assert_html_equal(actual_html, BASE_HTML % '''
+ Title
+ Text
+ ''')
def test_upper_alpha_all_bold():
@@ -752,12 +624,10 @@ def test_upper_alpha_all_bold():
'upper_alpha_all_bold.docx',
)
actual_html = convert(file_path)
- assert_html_equal(actual_html, '''
-
+ assert_html_equal(actual_html, BASE_HTML % '''
AAA
BBB
CCC
-
''')
@@ -769,14 +639,21 @@ def test_simple_table():
'simple_table.docx',
)
actual_html = convert(file_path)
- assert_html_equal(actual_html, '''
-
-
- Cell1 Cell3 | Cell2
- And I am writing in the table |
- | Cell4 |
+ assert_html_equal(actual_html, BASE_HTML % '''
+
+
+ Cell1
+ Cell3
+ |
+ Cell2
+ And I am writing in the table
+ |
+
+
+ |
+ Cell4 |
+
-
''')
@@ -788,21 +665,21 @@ def test_justification():
'justification.docx',
)
actual_html = convert(file_path)
- assert_html_equal(actual_html, '''
-
+ assert_html_equal(actual_html, BASE_HTML % '''
- Center Justified
+ Center Justified
- Right justified
+ Right justified
-
+
Right justified and pushed in from right
-
+
Center justified and pushed in from left and it is
great and it is the coolest thing of all time and I like it and
I think it is cool
@@ -813,7 +690,6 @@ def test_justification():
Left justified and pushed in from left
-
''')
diff --git a/pydocx/tests/test_xml.py b/pydocx/tests/test_xml.py
index fb1a47fe..4e5cf1a0 100644
--- a/pydocx/tests/test_xml.py
+++ b/pydocx/tests/test_xml.py
@@ -15,10 +15,8 @@
class BoldTestCase(_TranslationTestCase):
expected_output = """
-
- AAA
- BBB
-
+ AAA
+ BBB
"""
def get_xml(self):
@@ -40,9 +38,7 @@ class HyperlinkVanillaTestCase(_TranslationTestCase):
}
expected_output = '''
-
link.
-
'''
def get_xml(self):
@@ -61,9 +57,7 @@ class HyperlinkWithMultipleRunsTestCase(_TranslationTestCase):
}
expected_output = '''
-
link.
-
'''
def get_xml(self):
@@ -80,10 +74,7 @@ class HyperlinkNoTextTestCase(_TranslationTestCase):
'rId0': 'www.google.com',
}
- expected_output = '''
-
-
- '''
+ expected_output = ''
def get_xml(self):
run_tags = []
@@ -98,11 +89,7 @@ class HyperlinkNotInRelsDictTestCase(_TranslationTestCase):
# 'rId0': 'www.google.com', missing
}
- expected_output = '''
-
- link.
-
- '''
+ expected_output = ' link. '
def get_xml(self):
run_tags = []
@@ -119,11 +106,7 @@ class HyperlinkWithBreakTestCase(_TranslationTestCase):
'rId0': 'www.google.com',
}
- expected_output = '''
-
- link
-
- '''
+ expected_output = ' link
'
def get_xml(self):
run_tags = []
@@ -141,14 +124,12 @@ class ImageTestCase(_TranslationTestCase):
'rId1': 'media/image2.jpeg',
}
expected_output = '''
-
-
-
-
-
-
-
-
+
+
+
+
+
+
'''
def get_xml(self):
@@ -216,10 +197,7 @@ class ImageNotInRelsDictTestCase(_TranslationTestCase):
relationship_dict = {
# 'rId0': 'media/image1.jpeg',
}
- expected_output = '''
-
-
- '''
+ expected_output = ''
def get_xml(self):
drawing = DXB.drawing(height=20, width=40, r_id='rId0')
@@ -271,18 +249,16 @@ def get_xml(self):
class TableTag(_TranslationTestCase):
expected_output = '''
-
-
-
- | AAA |
- BBB |
-
-
- | CCC |
- DDD |
-
-
-
+
+
+ | AAA |
+ BBB |
+
+
+ | CCC |
+ DDD |
+
+
'''
def get_xml(self):
@@ -299,8 +275,7 @@ def get_xml(self):
class NestedTableTag(_TranslationTestCase):
expected_output = '''
-
-
+
| AAA |
BBB |
@@ -308,7 +283,7 @@ class NestedTableTag(_TranslationTestCase):
| CCC |
-
+
| DDD |
EEE |
@@ -321,7 +296,6 @@ class NestedTableTag(_TranslationTestCase):
-
'''
def get_xml(self):
@@ -344,18 +318,16 @@ def get_xml(self):
class TableWithInvalidTag(_TranslationTestCase):
expected_output = '''
-
-
-
- | AAA |
- BBB |
-
-
- |
- DDD |
-
-
-
+
+
+ | AAA |
+ BBB |
+
+
+ |
+ DDD |
+
+
'''
def get_xml(self):
@@ -374,11 +346,10 @@ def get_xml(self):
class TableWithListAndParagraph(_TranslationTestCase):
expected_output = '''
-
-
+
-
+
- AAA
- BBB
@@ -387,7 +358,6 @@ class TableWithListAndParagraph(_TranslationTestCase):
|
-
'''
def get_xml(self):
@@ -416,13 +386,11 @@ def get_xml(self):
class SimpleListTestCase(_TranslationTestCase):
expected_output = '''
-
-
- - AAA
- - BBB
- - CCC
-
-
+
+ - AAA
+ - BBB
+ - CCC
+
'''
# Ensure its not failing somewhere and falling back to decimal
@@ -448,11 +416,9 @@ def get_xml(self):
class SingleListItemTestCase(_TranslationTestCase):
expected_output = '''
-
-
- - AAA
-
-
+
+ - AAA
+
'''
# Ensure its not failing somewhere and falling back to decimal
@@ -476,24 +442,22 @@ def get_xml(self):
class ListWithContinuationTestCase(_TranslationTestCase):
expected_output = '''
-
-
- - AAA
BBB
- - CCC
-
-
- | DDD |
- EEE |
-
-
- | FFF |
- GGG |
-
-
-
- - HHH
-
-
+
+ - AAA
BBB
+ - CCC
+
+
+ | DDD |
+ EEE |
+
+
+ | FFF |
+ GGG |
+
+
+
+ - HHH
+
'''
def get_xml(self):
@@ -520,23 +484,21 @@ def get_xml(self):
class ListWithMultipleContinuationTestCase(_TranslationTestCase):
expected_output = '''
-
-
- - AAA
-
-
-
- - DDD
-
-
+
+ - AAA
+
+
+
+ - DDD
+
'''
def get_xml(self):
@@ -562,18 +524,16 @@ def get_xml(self):
class MangledIlvlTestCase(_TranslationTestCase):
expected_output = '''
-
-
+
- AAA
-
+
- BBB
-
+
- CCC
-
'''
def get_xml(self):
@@ -592,17 +552,15 @@ def get_xml(self):
class SeperateListsTestCase(_TranslationTestCase):
expected_output = '''
-
-
+
- AAA
-
+
- BBB
-
+
- CCC
-
'''
def get_xml(self):
@@ -624,19 +582,17 @@ def get_xml(self):
class InvalidIlvlOrderTestCase(_TranslationTestCase):
expected_output = '''
-
-
+
- AAA
-
+
- BBB
-
+
- CCC
-
'''
def get_xml(self):
@@ -654,8 +610,7 @@ def get_xml(self):
class DeeplyNestedTableTestCase(_TranslationTestCase):
- expected_output = '''
- '''
+ expected_output = ''
run_expected_output = False
def get_xml(self):
@@ -686,10 +641,8 @@ def test_performance(self):
class NonStandardTextTagsTestCase(_TranslationTestCase):
expected_output = '''
-
- insert
+ insert
smarttag
-
'''
def get_xml(self):
@@ -705,7 +658,7 @@ def get_xml(self):
class RTagWithNoText(_TranslationTestCase):
- expected_output = ''
+ expected_output = ''
def get_xml(self):
p_tag = DXB.p_tag(None) # No text
@@ -720,14 +673,12 @@ def get_xml(self):
class DeleteTagInList(_TranslationTestCase):
expected_output = '''
-
-
+
- AAA
- BBB
+ BBB
- CCC
-
'''
def get_xml(self):
@@ -744,14 +695,12 @@ def get_xml(self):
class InsertTagInList(_TranslationTestCase):
expected_output = '''
-
-
+
- AAA
- BBB
+ BBB
- CCC
-
'''
def get_xml(self):
@@ -769,14 +718,12 @@ def get_xml(self):
class SmartTagInList(_TranslationTestCase):
expected_output = '''
-
-
+
- AAA
BBB
- CCC
-
'''
def get_xml(self):
@@ -794,12 +741,10 @@ def get_xml(self):
class SingleListItem(_TranslationTestCase):
expected_output = '''
-
-
+
- AAA
BBB
-
'''
numbering_dict = {
@@ -822,11 +767,23 @@ def get_xml(self):
class SimpleTableTest(_TranslationTestCase):
expected_output = '''
-
- | Blank | Column 1 | Column 2 |
- | Row 1 | First | Second |
- | Row 2 | Third | Fourth |
- '''
+
+
+ | Blank |
+ Column 1 |
+ Column 2 |
+
+
+ | Row 1 |
+ First |
+ Second |
+
+
+ | Row 2 |
+ Third |
+ Fourth |
+
+ '''
def get_xml(self):
table = DXB.table(num_rows=3, num_columns=3, text=chain(
@@ -848,14 +805,12 @@ def get_xml(self):
class MissingIlvl(_TranslationTestCase):
expected_output = '''
-
-
+
- AAA
BBB
- CCC
-
'''
def get_xml(self):
@@ -874,13 +829,12 @@ def get_xml(self):
class SameNumIdInTable(_TranslationTestCase):
expected_output = '''
-
-
+
- AAA
-
+
-
+
- BBB
|
@@ -889,7 +843,6 @@ class SameNumIdInTable(_TranslationTestCase):
- CCC
-
'''
# Ensure its not failing somewhere and falling back to decimal
@@ -921,14 +874,12 @@ def get_xml(self):
class SDTTestCase(_TranslationTestCase):
expected_output = '''
-
-
+
- AAA
BBB
- CCC
-
'''
def get_xml(self):
| | |