Commits

Heikki Junes committed 15143a3

Fix for Python 3.2. The dictionary order does not necessary match the filling
order of the dictionary. Test therefore the resulting xml string in parts.

  • Participants
  • Parent commits 033373a

Comments (0)

Files changed (2)

openpyxl/tests/test_worksheet.py

         ws = Worksheet(self.wb)
         ws.set_printer_settings(Worksheet.PAPER_SIZE_LEGAL, Worksheet.ORIENTATION_LANDSCAPE)
         xml_string = write_worksheet(ws, None, None)
-        assert '<pageSetup paperSize="5" orientation="landscape"></pageSetup>' in xml_string
+        assert '<pageSetup' in xml_string
+        assert 'paperSize="5"' in xml_string
+        assert 'orientation="landscape"' in xml_string
+        assert '</pageSetup>' in xml_string
 
         ws = Worksheet(self.wb)
         xml_string = write_worksheet(ws, None, None)
-        assert "<pageSetup paperSize" not in xml_string        
-        
+        assert "<pageSetup" not in xml_string
+        

openpyxl/writer/worksheet.py

         tag(doc, 'autoFilter', {'ref': worksheet.auto_filter})
     write_worksheet_hyperlinks(doc, worksheet)
     
-    if worksheet.paper_size is not None:        #size and orientation set in common setter, so expect both or neither
-        tag(doc, 'pageSetup', {'paperSize':'%s' % worksheet.paper_size,'orientation':'%s' % worksheet.orientation}) 
+    if worksheet.paper_size is not None:        
+        # size and orientation set in common setter, so expect both or neither
+        tag(doc, 'pageSetup', 
+                {'paperSize': '%s' % (worksheet.paper_size),
+                 'orientation': '%s' % (worksheet.orientation)})
     
     if worksheet._charts:
         tag(doc, 'drawing', {'r:id':'rId1'})