/[thuban]/branches/WIP-pyshapelib-bramz/test/test_load.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/test/test_load.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1846 by bh, Tue Oct 21 10:49:53 2003 UTC revision 1931 by bh, Tue Nov 11 13:24:45 2003 UTC
# Line 179  class TestSingleLayer(LoadSessionTest): Line 179  class TestSingleLayer(LoadSessionTest):
179  <?xml version="1.0" encoding="UTF-8"?>  <?xml version="1.0" encoding="UTF-8"?>
180  <!DOCTYPE session SYSTEM "thuban-1.0.dtd">  <!DOCTYPE session SYSTEM "thuban-1.0.dtd">
181  <session xmlns="http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd"  <session xmlns="http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd"
182          title="single map&amp;layer">          title="Stra\xc3\x9fen &amp; Landmarken">
183      <fileshapesource filetype="shapefile" id="D1"      <fileshapesource filetype="shapefile" id="D1"
184          filename="../../Data/iceland/political.shp"/>          filename="../../Data/iceland/political.shp"/>
185      <map title="Test Map">      <map title="\xc3\x9cbersicht">
186          <projection epsg="32627" name="WGS 84 / UTM zone 27N">          <projection epsg="32627" name="WGS 84 / UTM zone 27N">
187              <parameter value="datum=WGS84"/>              <parameter value="datum=WGS84"/>
188              <parameter value="ellps=WGS84"/>              <parameter value="ellps=WGS84"/>
# Line 191  class TestSingleLayer(LoadSessionTest): Line 191  class TestSingleLayer(LoadSessionTest):
191              <parameter value="zone=27"/>              <parameter value="zone=27"/>
192          </projection>          </projection>
193          <layer shapestore="D1" visible="true"          <layer shapestore="D1" visible="true"
194                  stroke="#000000" title="My Layer" stroke_width="1"                  stroke="#000000" title="K\xc3\xbcste" stroke_width="1"
195                  fill="None"/>                  fill="None"/>
196      </map>      </map>
197  </session>  </session>
# Line 204  class TestSingleLayer(LoadSessionTest): Line 204  class TestSingleLayer(LoadSessionTest):
204          self.session = session          self.session = session
205    
206          # Check the title          # Check the title
207          eq(session.Title(), "single map&layer")          eq(session.Title(), "Stra\xdfen & Landmarken")
208    
209          # the session has one map.          # the session has one map.
210          maps = session.Maps()          maps = session.Maps()
# Line 212  class TestSingleLayer(LoadSessionTest): Line 212  class TestSingleLayer(LoadSessionTest):
212    
213          # Check the map's attributes          # Check the map's attributes
214          map = maps[0]          map = maps[0]
215          eq(map.Title(), "Test Map")          eq(map.Title(), "\xdcbersicht")
216          proj = map.GetProjection()          proj = map.GetProjection()
217          eq(proj.GetName(), "WGS 84 / UTM zone 27N")          eq(proj.GetName(), "WGS 84 / UTM zone 27N")
218          eq(proj.EPSGCode(), "32627")          eq(proj.EPSGCode(), "32627")
# Line 227  class TestSingleLayer(LoadSessionTest): Line 227  class TestSingleLayer(LoadSessionTest):
227    
228          # Check the layer attributes          # Check the layer attributes
229          layer = layers[0]          layer = layers[0]
230          eq(layer.Title(), "My Layer")          eq(layer.Title(), "K\xfcste")
231          self.failUnless(filenames_equal(layer.ShapeStore().FileName(),          self.failUnless(filenames_equal(layer.ShapeStore().FileName(),
232                                          os.path.join(self.temp_dir(),                                          os.path.join(self.temp_dir(),
233                                                       os.pardir, os.pardir,                                                       os.pardir, os.pardir,
# Line 242  class TestSingleLayer(LoadSessionTest): Line 242  class TestSingleLayer(LoadSessionTest):
242          self.session.Destroy()          self.session.Destroy()
243          self.session = None          self.session = None
244    
245        def test_leak(self):
246            """Test load_session for resource leaks
247    
248            The load_session function had a resource leak in that it created
249            cyclic references. The objects would have been eventually
250            collected by the garbage collector but too late. One symptom is
251            that when layers are removed so that the last normal reference
252            owned indirectly by the session to a shape store goes away, the
253            shape store is not actually removed from the session even though
254            the session only keeps weak references because there are still
255            references owned by the cyclic garbage.
256            """
257            session = load_session(self.filename())
258            self.session = session
259    
260            # sanity check
261            self.assertEquals(len(session.ShapeStores()), 1)
262    
263            # remove the map. The shapestore should go away too
264            session.RemoveMap(session.Maps()[0])
265            self.assertEquals(len(session.ShapeStores()), 0)
266    
267    
268  class TestLayerVisibility(LoadSessionTest):  class TestLayerVisibility(LoadSessionTest):
269    

Legend:
Removed from v.1846  
changed lines
  Added in v.1931

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26