Example #1
0
 def test_render_row_null_template(self):
     template_row = None
     row = render.render_row([42, 'Noé!>', 24], template_row, 2)
     ETree.fromstring(row)
     self.assertEqual(
         row, '<row r="2">'
         '<c r="A2" t="inlineStr"><is><t>42</t></is></c>'
         '<c r="B2" t="inlineStr"><is><t>Noé!&gt;</t></is></c>'
         '<c r="C2" t="inlineStr"><is><t>24</t></is></c>'
         '</row>'.encode())
Example #2
0
 def test_render_row_wrong_template(self):
     template_row = self.gen_row()
     row = render.render_row([42, 'Noé!>', 24, 'NoTemplateElement'],
                             template_row, 1)
     ETree.fromstring(row)
     self.assertEqual(
         row, '<row r="1">'
         '<c r="A1" t="inlineStr"><is><t>42</t></is></c>'
         '<c r="B1" t="inlineStr"><is><t>Noé!&gt;</t></is></c>'
         '<c r="C1" t="inlineStr"><is><t>24</t></is></c>'
         '<c r="D1" t="inlineStr"><is><t>NoTemplateElement</t></is></c>'
         '</row>'.encode())
 def test_render_row(self):
     template_row = self.gen_row()
     row = render.render_row([42, "Noé!>", 24], template_row, 12)
     ETree.fromstring(row)
     self.assertEqual(
         row,
         '<row r="12">'
         '<c r="A12" t="n"><v>42</v></c>'
         '<c r="B12" t="inlineStr"><is><t>Noé!&gt;</t></is></c>'
         '<c r="C12"><v>24</v></c>'
         "</row>".encode("utf-8"),
     )
 def test_render_row_null_template(self):
     template_row = None
     row = render.render_row([42, "Noé!>", 24], template_row, 2)
     ETree.fromstring(row)
     self.assertEqual(
         row,
         '<row r="2">'
         '<c r="A2" t="inlineStr"><is><t>42</t></is></c>'
         '<c r="B2" t="inlineStr"><is><t>Noé!&gt;</t></is></c>'
         '<c r="C2" t="inlineStr"><is><t>24</t></is></c>'
         "</row>".encode("utf-8"),
     )
Example #5
0
 def test_render_row(self):
     template_row = self.gen_row()
     row = render.render_row([42, 'Noé!>', 24], template_row, 12)
     ETree.fromstring(row)
     self.assertEqual(
         row,
         '<row r="12">'
         '<c r="A12" t="n"><v>42</v></c>'
         '<c r="B12" t="inlineStr"><is><t>Noé!&gt;</t></is></c>'
         '<c r="C12"><v>24</v></c>'
         '</row>'.encode('utf-8')
     )
 def test_render_row_wrong_template(self):
     template_row = self.gen_row()
     row = render.render_row([42, "Noé!>", 24, "NoTemplateElement"], template_row, 1)
     ETree.fromstring(row)
     self.assertEqual(
         row,
         '<row r="1">'
         '<c r="A1" t="inlineStr"><is><t>42</t></is></c>'
         '<c r="B1" t="inlineStr"><is><t>Noé!&gt;</t></is></c>'
         '<c r="C1" t="inlineStr"><is><t>24</t></is></c>'
         '<c r="D1" t="inlineStr"><is><t>NoTemplateElement</t></is></c>'
         "</row>".encode("utf-8"),
     )
Example #7
0
 def test_render_row(self):
     template_row = self.gen_row()
     row = render.render_row([42, 'Noé!>', 24], template_row, 12)
     ETree.fromstring(row)
     # Starting from Python 3.8, ElementTree preserves the
     # attribute order specified by the user. Before 3.8,
     # attributes were ordered alphabetically.
     if sys.version[:3] >= '3.8':
         expected = ('<row r="12">'
                     '<c t="n" r="A12"><v>42</v></c>'
                     '<c t="inlineStr" r="B12"><is><t>Noé!&gt;</t></is></c>'
                     '<c r="C12"><v>24</v></c>'
                     '</row>'.encode())
     else:
         expected = ('<row r="12">'
                     '<c r="A12" t="n"><v>42</v></c>'
                     '<c r="B12" t="inlineStr"><is><t>Noé!&gt;</t></is></c>'
                     '<c r="C12"><v>24</v></c>'
                     '</row>'.encode())
     self.assertEqual(row, expected)