14 |
# $Id$ |
# $Id$ |
15 |
|
|
16 |
import unittest |
import unittest |
17 |
|
import os |
18 |
|
|
19 |
import support |
import support |
20 |
support.initthuban() |
support.initthuban() |
25 |
|
|
26 |
from test_save import sax_eventlist |
from test_save import sax_eventlist |
27 |
|
|
28 |
|
from xml.sax import SAXParseException |
29 |
|
|
30 |
|
|
31 |
class TestProjection(unittest.TestCase, support.FloatComparisonMixin): |
class TestProjection(unittest.TestCase, support.FloatComparisonMixin): |
32 |
|
|
120 |
self.doTestRead(sample_projfile_data, sample_projfile) |
self.doTestRead(sample_projfile_data, sample_projfile) |
121 |
self.doTestRead(sample_projfile_data2, sample_projfile2) |
self.doTestRead(sample_projfile_data2, sample_projfile2) |
122 |
|
|
123 |
|
# |
124 |
|
# file doesn't exist |
125 |
|
# |
126 |
|
self.assertRaises(IOError, |
127 |
|
resource.ReadProjFile, self.temp_file_name("nonexistent.proj")) |
128 |
|
|
129 |
|
# |
130 |
|
# file isn't readable |
131 |
|
# |
132 |
|
filename = self.temp_file_name("projfile.proj") |
133 |
|
file = open(filename, "w") |
134 |
|
file.close() |
135 |
|
os.chmod(filename, 0200) # write-only |
136 |
|
self.assertRaises(IOError, resource.ReadProjFile, filename) |
137 |
|
os.chmod(filename, 0600) # read/write so we reuse the file |
138 |
|
|
139 |
|
# |
140 |
|
# file has invalid XML (or none at all) |
141 |
|
# |
142 |
|
filename = self.temp_file_name("projfile.proj") |
143 |
|
file = open(filename, "w") |
144 |
|
file.close() |
145 |
|
|
146 |
|
self.assertRaises(SAXParseException, resource.ReadProjFile, filename) |
147 |
|
|
148 |
def testWrite(self): |
def testWrite(self): |
149 |
"""Test WriteProjFile""" |
"""Test WriteProjFile""" |
150 |
|
|