equal
deleted
inserted
replaced
14 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
14 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
15 # details. |
15 # details. |
16 # |
16 # |
17 # You should have received a copy of the GNU Lesser General Public License along |
17 # You should have received a copy of the GNU Lesser General Public License along |
18 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
19 |
|
20 from six import text_type |
|
21 |
19 |
22 from cubicweb import ValidationError |
20 from cubicweb import ValidationError |
23 from cubicweb.devtools.testlib import CubicWebTC |
21 from cubicweb.devtools.testlib import CubicWebTC |
24 from cubicweb.server.session import Connection |
22 from cubicweb.server.session import Connection |
25 |
23 |
252 self.assertUndoTransaction(cnx, txuuid, [ |
250 self.assertUndoTransaction(cnx, txuuid, [ |
253 u"Can't restore relation in_group, object entity " |
251 u"Can't restore relation in_group, object entity " |
254 "%s doesn't exist anymore." % g.eid]) |
252 "%s doesn't exist anymore." % g.eid]) |
255 with self.assertRaises(ValidationError) as cm: |
253 with self.assertRaises(ValidationError) as cm: |
256 cnx.commit() |
254 cnx.commit() |
257 cm.exception.translate(text_type) |
255 cm.exception.translate(str) |
258 self.assertEqual(cm.exception.entity, self.totoeid) |
256 self.assertEqual(cm.exception.entity, self.totoeid) |
259 self.assertEqual(cm.exception.errors, |
257 self.assertEqual(cm.exception.errors, |
260 {'in_group-subject': u'at least one relation in_group is ' |
258 {'in_group-subject': u'at least one relation in_group is ' |
261 'required on CWUser (%s)' % self.totoeid}) |
259 'required on CWUser (%s)' % self.totoeid}) |
262 |
260 |
456 |
454 |
457 |
455 |
458 class UndoExceptionInUnicode(CubicWebTC): |
456 class UndoExceptionInUnicode(CubicWebTC): |
459 |
457 |
460 # problem occurs in string manipulation for python < 2.6 |
458 # problem occurs in string manipulation for python < 2.6 |
461 def test___unicode__method(self): |
459 def test___str__method(self): |
462 u = _UndoException(u"voilĂ ") |
460 u = _UndoException(u"voilĂ ") |
463 self.assertIsInstance(text_type(u), text_type) |
461 self.assertIsInstance(str(u), str) |
464 |
462 |
465 |
463 |
466 if __name__ == '__main__': |
464 if __name__ == '__main__': |
467 from logilab.common.testlib import unittest_main |
465 from logilab.common.testlib import unittest_main |
468 unittest_main() |
466 unittest_main() |