bernhard: thuban/Extensions/svgexport/test test_svgmapwriter.py, 1.2, 1.3

cvs@intevation.de cvs at intevation.de
Mon Jun 28 12:55:13 CEST 2004


Author: bernhard

Update of /thubanrepository/thuban/Extensions/svgexport/test
In directory doto:/tmp/cvs-serv23092/Extensions/svgexport/test

Modified Files:
	test_svgmapwriter.py 
Log Message:
* Extensions/svgexport/test/test_svgmapwriter.py: 
	Removed class VFile and used standard StringIO instead.


Index: test_svgmapwriter.py
===================================================================
RCS file: /thubanrepository/thuban/Extensions/svgexport/test/test_svgmapwriter.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- test_svgmapwriter.py	20 Feb 2004 15:49:36 -0000	1.2
+++ test_svgmapwriter.py	28 Jun 2004 10:55:10 -0000	1.3
@@ -14,6 +14,7 @@
 
 import os
 import sys
+import StringIO
 import unittest
 
 # If run directly as a script, add Thuban's test directory to the path.
@@ -34,23 +35,6 @@
 # We use xmlsupport to verify the SVG output
 import xmlsupport
 
-class VFile:
-    '''A virtual file to show which contents would have been
-    written to a file.'''
-    
-    def open(self, filename, mode="w"): 
-        '''Compatibility function - initializes an empty string.'''
-        self.str = ""
-
-    def write(self, string):
-        '''The file.write function to capture all input.'''
-        if hasattr(self, "str"):
-            self.str += string
-        else: 
-            self.str = ""
-            self.str += string
-
-
 class TestVirtualDC(unittest.TestCase):
     '''Tests the VirtualDC class that imitates a wxDC and writes
     SVGRenderer instead.'''
@@ -70,12 +54,12 @@
     def test_clippath(self):
         '''Define a clipping region and close it afterwards.'''
         data = '<clipPath id="testid">\n</clipPath>'
-        file = VFile()
+        file = StringIO.StringIO()
         dc = VirtualDC(file)
         dc.BeginClipPath('testid')
         dc.EndClipPath()
         self.assertEquals(xmlsupport.sax_eventlist(data = data), 
-                          xmlsupport.sax_eventlist(data = file.str))
+                          xmlsupport.sax_eventlist(data = file.getvalue()))
         
     def test_polygon_closed(self):
         '''Set drawing properties and draw a polygon onto the dc.'''
@@ -83,14 +67,14 @@
                 'stroke-width:3; stroke-linecap:round; fill:#00ff00" ' 
                 'meta="Object:test; Label:nothing" d="M 5.6 5.5 '
                 'L 95.4 5.3 L 95.2 95.1 L 5.0 95.0 L 5.0 5.0 Z"/>')
-        file = VFile()
+        file = StringIO.StringIO()
         dc = VirtualDC(file)
         dc.SetPen(self.solid_pen)
         dc.SetMeta(self.meta)
         dc.SetBrush(self.solid_brush)
         dc.DrawPolygon(self.polygon, 1)
         self.assertEquals(xmlsupport.sax_eventlist(data = data), 
-                          xmlsupport.sax_eventlist(data = file.str))
+                          xmlsupport.sax_eventlist(data = file.getvalue()))
     
     def test_polygon_opened(self):
         '''Set drawing properties and draw a polygon onto the dc.'''
@@ -98,14 +82,14 @@
                 'stroke-width:3; stroke-linecap:round; fill:#00ff00" ' 
                 'meta="Object:test; Label:nothing" d="M 5.6 5.5 '
                 'L 95.4 5.3 L 95.2 95.1 L 5.0 95.0 L 5.0 5.0 "/>')
-        file = VFile()
+        file = StringIO.StringIO()
         dc = VirtualDC(file)
         dc.SetPen(self.solid_pen)
         dc.SetMeta(self.meta)
         dc.SetBrush(self.solid_brush)
         dc.DrawPolygon(self.polygon, 0)
         self.assertEquals(xmlsupport.sax_eventlist(data = data), 
-                          xmlsupport.sax_eventlist(data = file.str))
+                          xmlsupport.sax_eventlist(data = file.getvalue()))
     
     def test_rect(self):
         '''Set drawing properties and draw a rectangle'''
@@ -113,64 +97,64 @@
                 'style="stroke-linejoin:round; stroke:#ff00ff; '
                 'stroke-width:3; stroke-linecap:round; fill:none" '
                 'meta="Object:test; Label:nothing"/>')
-        file = VFile()
+        file = StringIO.StringIO()
         dc = VirtualDC(file)
         dc.SetPen(self.solid_pen)
         dc.SetMeta(self.meta)
         dc.SetBrush(self.trans_brush)
         dc.DrawRectangle(5.5, 5.4, 90.3, 90.2)
         self.assertEquals(xmlsupport.sax_eventlist(data = data), 
-                          xmlsupport.sax_eventlist(data = file.str))
+                          xmlsupport.sax_eventlist(data = file.getvalue()))
     
     def test_circle(self):
         '''Set drawing properties and draw a circle'''
         data = ('<circle cx="5.5" cy="5.3" r="90.1"  style="'
                 'fill:#00ff00" meta="Object:test; Label:nothing"/>')
-        file = VFile()
+        file = StringIO.StringIO()
         dc = VirtualDC(file)
         dc.SetPen(self.trans_pen)
         dc.SetMeta(self.meta)
         dc.SetBrush(self.solid_brush)
         dc.DrawCircle(5.5, 5.3, 90.1)
         self.assertEquals(xmlsupport.sax_eventlist(data = data), 
-                          xmlsupport.sax_eventlist(data = file.str))
+                          xmlsupport.sax_eventlist(data = file.getvalue()))
     
     def test_ellipse(self):
         '''Set drawing properties and draw a circle'''
         data = ('<ellipse cx="5.5" cy="5.3" rx="90.1" ry="100.321"  style="'
                 'fill:#00ff00" meta="Object:test; Label:nothing"/>')
-        file = VFile()
+        file = StringIO.StringIO()
         dc = VirtualDC(file)
         dc.SetPen(self.trans_pen)
         dc.SetMeta(self.meta)
         dc.SetBrush(self.solid_brush)
         dc.DrawEllipse(5.5, 5.3, 90.1, 100.321)
         self.assertEquals(xmlsupport.sax_eventlist(data = data), 
-                          xmlsupport.sax_eventlist(data = file.str))
+                          xmlsupport.sax_eventlist(data = file.getvalue()))
     
     def test_text(self):
         '''Set drawing properties and draw a circle'''
         data = ('<text x="123.321" y="1515.5151" style="font-size:12; '
                 'font-family:Helvetica; fill:#000000" >Some text.</text>')
-        file = VFile()
+        file = StringIO.StringIO()
         dc = VirtualDC(file)
         dc.SetTextForeground(self.black)
         dc.SetFont(self.font)
         dc.DrawText('Some text.', 123.321, 1515.5151)
         self.assertEquals(xmlsupport.sax_eventlist(data = data), 
-                          xmlsupport.sax_eventlist(data = file.str))
+                          xmlsupport.sax_eventlist(data = file.getvalue()))
     
     def test_document(self):
         '''Set up a document with a dimension and 
         latin encoding'''
         data = ('<?xml version="1.0" encoding="ISO-8859-1" standalone'
                 '="yes"?>\n<svg>\n</svg>')
-        file = VFile()
+        file = StringIO.StringIO()
         dc = VirtualDC(file)
         dc.BeginExport()
         dc.EndExport()
         self.assertEquals(xmlsupport.sax_eventlist(data = data), 
-                          xmlsupport.sax_eventlist(data = file.str))
+                          xmlsupport.sax_eventlist(data = file.getvalue()))
 
 
 if __name__ == "__main__":





More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)