# HG changeset patch # User Sylvain Thénault # Date 1267020037 -3600 # Node ID c19366a12281755648e443af4fe7a507f1fbab1e # Parent 1eaf5ce048446e4a8028dd514a69a2e7b7b5acf5 simplejson may not be available with python 2.4 diff -r 1eaf5ce04844 -r c19366a12281 test/unittest_utils.py --- a/test/unittest_utils.py Wed Feb 24 15:00:15 2010 +0100 +++ b/test/unittest_utils.py Wed Feb 24 15:00:37 2010 +0100 @@ -6,14 +6,18 @@ :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses """ -from logilab.common.testlib import TestCase, unittest_main - -import simplejson +import re import decimal import datetime -from cubicweb.utils import make_uid, UStringIO, SizeConstrainedList, CubicWebJsonEncoder +from logilab.common.testlib import TestCase, unittest_main +from cubicweb.utils import make_uid, UStringIO, SizeConstrainedList +try: + import simplejson + from cubicweb.utils import CubicWebJsonEncoder +except ImportError: + simplejson = None class MakeUidTC(TestCase): def test_1(self): @@ -26,6 +30,9 @@ uid = make_uid('xyz') if uid in d: self.fail(len(d)) + if re.match('\d', uid): + self.fail('make_uid must not return something begining with ' + 'some numeric character, got %s' % uid) d.add(uid) @@ -53,6 +60,9 @@ yield self.assertEquals, l, expected class JSONEncoerTests(TestCase): + def setUp(self): + if simplejson is None: + self.skip('simplejson not available') def encode(self, value): return simplejson.dumps(value, cls=CubicWebJsonEncoder)