52 |
"""Destroy all objects in self.to_destroy and clear the message list""" |
"""Destroy all objects in self.to_destroy and clear the message list""" |
53 |
for obj in self.to_destroy: |
for obj in self.to_destroy: |
54 |
obj.Destroy() |
obj.Destroy() |
55 |
|
self.to_destroy = None |
56 |
|
self.session = None |
57 |
|
self.selection = None |
58 |
self.clear_messages() |
self.clear_messages() |
59 |
|
|
60 |
def get_layer(self): |
def get_layer(self): |
61 |
"""Return a layer to have something to test with""" |
"""Return a layer to have something to test with. |
62 |
|
|
63 |
|
Also, instantiate self.session if not done already. The layer |
64 |
|
(and the session when it is created) are added to |
65 |
|
self.to_destroy so that they are properly destroyed at the end |
66 |
|
of the test. |
67 |
|
|
68 |
|
The layer should not be added to a map in the session to avoid a |
69 |
|
situation where its destroy method is called twice. This |
70 |
|
situation should not arise in the selection tests. |
71 |
|
""" |
72 |
|
if not hasattr(self, "session"): |
73 |
|
self.session = Session("Test Session for %s" % self.__class__) |
74 |
|
self.to_destroy.append(self.session) |
75 |
|
filename = os.path.join("..", "Data", "iceland", "roads-line.shp") |
76 |
layer = Layer("Selection Test Layer", |
layer = Layer("Selection Test Layer", |
77 |
os.path.join("..", "Data", "iceland", "roads-line.shp")) |
self.session.OpenShapefile(filename)) |
78 |
self.to_destroy.append(layer) |
self.to_destroy.append(layer) |
79 |
return layer |
return layer |
80 |
|
|
301 |
|
|
302 |
|
|
303 |
if __name__ == "__main__": |
if __name__ == "__main__": |
304 |
unittest.main() |
support.run_tests() |