/[thuban]/trunk/thuban/test/test_save.py
ViewVC logotype

Diff of /trunk/thuban/test/test_save.py

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

revision 292 by bh, Fri Aug 30 09:44:12 2002 UTC revision 723 by bh, Thu Apr 24 15:31:53 2003 UTC
# Line 1  Line 1 
1  # Copyright (c) 2002 by Intevation GmbH  # Copyright (c) 2002, 2003 by Intevation GmbH
2  # Authors:  # Authors:
3  # Bernhard Herzog <[email protected]>  # Bernhard Herzog <[email protected]>
4  #  #
# Line 19  from StringIO import StringIO Line 19  from StringIO import StringIO
19    
20  import xml.sax  import xml.sax
21  import xml.sax.handler  import xml.sax.handler
22  from xml.sax import make_parser, ErrorHandler  from xml.sax import make_parser, ErrorHandler, SAXNotRecognizedException
23    
24  import support  import support
25  support.initthuban()  support.initthuban()
# Line 54  def sax_eventlist(data): Line 54  def sax_eventlist(data):
54      parser.setErrorHandler(ErrorHandler())      parser.setErrorHandler(ErrorHandler())
55      parser.setFeature(xml.sax.handler.feature_namespaces, 1)      parser.setFeature(xml.sax.handler.feature_namespaces, 1)
56    
57        #
58        # see comment at the end of Thuban/Model/load.py
59        #
60        try:
61            parser.setFeature(xml.sax.handler.feature_validation, 0)
62            parser.setFeature(xml.sax.handler.feature_external_ges, 0)
63            parser.setFeature(xml.sax.handler.feature_external_pes, 0)
64        except SAXNotRecognizedException:
65            pass
66    
67      inpsrc = xml.sax.InputSource()      inpsrc = xml.sax.InputSource()
68      inpsrc.setByteStream(StringIO(data))      inpsrc.setByteStream(StringIO(data))
69      parser.parse(inpsrc)      parser.parse(inpsrc)
# Line 90  class SaveSessionTest(unittest.TestCase, Line 100  class SaveSessionTest(unittest.TestCase,
100          # use shapefile from the example data          # use shapefile from the example data
101          shpfile = os.path.join(os.path.dirname(__file__),          shpfile = os.path.join(os.path.dirname(__file__),
102                                 os.pardir, "Data", "iceland", "political.shp")                                 os.pardir, "Data", "iceland", "political.shp")
103          layer = Layer("My Layer", shpfile)          layer = Layer("My Layer", session.OpenShapefile(shpfile))
104          map.AddLayer(layer)          map.AddLayer(layer)
105    
106          filename = self.temp_file_name("save_singlemap.thuban")          filename = self.temp_file_name("save_singlemap.thuban")
# Line 114  class SaveSessionTest(unittest.TestCase, Line 124  class SaveSessionTest(unittest.TestCase,
124              </map>              </map>
125          </session>''' % os.path.join("..", "..", "Data", "iceland",          </session>''' % os.path.join("..", "..", "Data", "iceland",
126                                       "political.shp")                                       "political.shp")
127            #print written_contents
128            #print "********************************************"
129            #print expected_contents
130          self.compare_xml(written_contents, expected_contents)          self.compare_xml(written_contents, expected_contents)
131    
132    
# Line 122  if __name__ == "__main__": Line 135  if __name__ == "__main__":
135      # Fake the __file__ global because it's needed by a test      # Fake the __file__ global because it's needed by a test
136      import sys      import sys
137      __file__ = sys.argv[0]      __file__ = sys.argv[0]
138      unittest.main()      support.run_tests()

Legend:
Removed from v.292  
changed lines
  Added in v.723

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26