equal
deleted
inserted
replaced
14 # details. |
14 # details. |
15 # |
15 # |
16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """unit tests for module cubicweb.schema""" |
18 """unit tests for module cubicweb.schema""" |
|
19 |
|
20 from __future__ import with_statement |
19 |
21 |
20 import sys |
22 import sys |
21 from os.path import join, isabs, basename, dirname |
23 from os.path import join, isabs, basename, dirname |
22 |
24 |
23 from logilab.common.testlib import TestCase, unittest_main |
25 from logilab.common.testlib import TestCase, unittest_main |
277 self.loader.post_build_callbacks = [] |
279 self.loader.post_build_callbacks = [] |
278 self.loader._pyreader = PyFileReader(self.loader) |
280 self.loader._pyreader = PyFileReader(self.loader) |
279 |
281 |
280 def _test(self, schemafile, msg): |
282 def _test(self, schemafile, msg): |
281 self.loader.handle_file(join(DATADIR, schemafile)) |
283 self.loader.handle_file(join(DATADIR, schemafile)) |
282 ex = self.assertRaises(BadSchemaDefinition, |
284 with self.assertRaises(BadSchemaDefinition) as cm: |
283 self.loader._build_schema, 'toto', False) |
285 self.loader._build_schema('toto', False) |
284 self.assertEqual(str(ex), msg) |
286 self.assertEqual(str(cm.exception), msg) |
285 |
287 |
286 def test_rrqlexpr_on_etype(self): |
288 def test_rrqlexpr_on_etype(self): |
287 self._test('rrqlexpr_on_eetype.py', |
289 self._test('rrqlexpr_on_eetype.py', |
288 "can't use RRQLExpression on ToTo, use an ERQLExpression") |
290 "can't use RRQLExpression on ToTo, use an ERQLExpression") |
289 |
291 |