# HG changeset patch # User Sylvain Thénault # Date 1309271558 -7200 # Node ID c5ee33fb6a3b374e1a0b8abeaf5de1c05e9b9cc4 # Parent d6366de1d0dc55989000e25384176dce1fae5ae8 [test] run and fix utils and uilib doctests diff -r d6366de1d0dc -r c5ee33fb6a3b test/unittest_uilib.py --- a/test/unittest_uilib.py Tue Jun 28 13:16:09 2011 +0200 +++ b/test/unittest_uilib.py Tue Jun 28 16:32:38 2011 +0200 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This file is part of CubicWeb. @@ -22,14 +22,15 @@ import pkg_resources -from logilab.common.testlib import TestCase, unittest_main + from unittest2 import skipIf +from logilab.common.testlib import DocTest, TestCase, unittest_main + from cubicweb import uilib lxml_version = pkg_resources.get_distribution('lxml').version.split('.') - class UILIBTC(TestCase): def test_remove_tags(self): @@ -185,6 +186,10 @@ self.assertMultiLineEqual(uilib.soup2xhtml(incoming, 'ascii'), expected) +class DocTest(DocTest): + module = uilib + + if __name__ == '__main__': unittest_main() diff -r d6366de1d0dc -r c5ee33fb6a3b test/unittest_utils.py --- a/test/unittest_utils.py Tue Jun 28 13:16:09 2011 +0200 +++ b/test/unittest_utils.py Tue Jun 28 16:32:38 2011 +0200 @@ -1,4 +1,4 @@ -# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This file is part of CubicWeb. @@ -21,7 +21,7 @@ import decimal import datetime -from logilab.common.testlib import TestCase, unittest_main +from logilab.common.testlib import TestCase, DocTest, unittest_main from cubicweb.utils import make_uid, UStringIO, SizeConstrainedList, RepeatList from cubicweb.entity import Entity @@ -156,5 +156,8 @@ self.assertEqual(self.encode(TestCase), 'null') +class DocTest(DocTest): + from cubicweb import utils as module + if __name__ == '__main__': unittest_main() diff -r d6366de1d0dc -r c5ee33fb6a3b utils.py --- a/utils.py Tue Jun 28 13:16:09 2011 +0200 +++ b/utils.py Tue Jun 28 16:32:38 2011 +0200 @@ -130,11 +130,11 @@ class SizeConstrainedList(list): - """simple list that makes sure the list does not get bigger - than a given size. + """simple list that makes sure the list does not get bigger than a given + size. - when the list is full and a new element is added, the first - element of the list is removed before appending the new one + when the list is full and a new element is added, the first element of the + list is removed before appending the new one >>> l = SizeConstrainedList(2) >>> l.append(1) @@ -142,6 +142,7 @@ >>> l [1, 2] >>> l.append(3) + >>> l [2, 3] """ def __init__(self, maxsize):