[MERGE] Make knits the default format

Robert Collins robertc at robertcollins.net
Thu Apr 20 03:00:34 BST 2006


On Thu, 2006-04-20 at 11:48 +1000, Martin Pool wrote:
> On 20 Apr 2006, Robert Collins <robertc at robertcollins.net> wrote:
> > Again, theres more than 'just toggle the default' - because if there
> > isn't, tests dont pass.
> 
> This will refuse to load any existing experimental knits - people will
> have to re-convert any branches they may have made.
> 
> +1 with some fixes.

> > === modified file 'a/bzrlib/tests/__init__.py'
> > --- a/bzrlib/tests/__init__.py	
> > +++ b/bzrlib/tests/__init__.py	
> > @@ -341,7 +341,8 @@
> >      def assertIsInstance(self, obj, kls):
> >          """Fail if obj is not an instance of kls"""
> >          if not isinstance(obj, kls):
> > -            self.fail("%r is not an instance of %s" % (obj, kls))
> > +            self.fail("%r is an instance of %s rather than %s" % (
> > +                obj, obj.__class__, kls))
> 
> Is it safe to do __class__ on any object?  It seems to work even for
> None or other primitives.

AFAIK yes, and even if it fails it will tell one something.

> > === modified file 'a/bzrlib/tests/revisionstore_implementations/test_all.py'
> > --- a/bzrlib/tests/revisionstore_implementations/test_all.py	
> > +++ b/bzrlib/tests/revisionstore_implementations/test_all.py	
> > @@ -107,7 +107,9 @@
> >          # we get a revision count and a numeric size figure from total_size().
> >          count, bytes = self.store.total_size(self.transaction)
> >          self.assertEqual(0, count)
> > -        self.assertEqual(0, bytes)
> > +        # some stores use disk immediately that they are created so we just 
> > +        # check that its an int.
> > +        self.assertIsInstance(bytes, (int, long))
> >          self.add_sample_rev()
> >          count, bytes = self.store.total_size(self.transaction)
> >          self.assertEqual(1, count)
> 
> This test is a bit deceptive - it looks like it checks they are an int
> and a long, but it actually just checks its a tuple.  Being able to
> check that something matches such a template might be nice, but
> assertIsInstance isn't that method.  For clarity, either check them
> separately or just check it's a tuple.

No, it checks its an int or a long. Check pydoc isinstance :).

> > === modified file 'a/bzrlib/tests/test_osutils.py'
> > --- a/bzrlib/tests/test_osutils.py	
> > +++ b/bzrlib/tests/test_osutils.py	
> > @@ -90,3 +90,16 @@
> >          self.assertRaises(BzrBadParameterNotUnicode,
> >                            osutils.safe_unicode,
> >                            '\xbb\xbb')
> > +
> > +
> > +class TestSplitLines(TestCase):
> > +
> > +    def test_split_unicode(self):
> > +        self.assertEqual([u'foo\n', u'bar\xae'],
> > +                         osutils.split_lines(u'foo\nbar\xae'))
> > +        self.assertEqual([u'foo\n', u'bar\xae\n'],
> > +                         osutils.split_lines(u'foo\nbar\xae\n'))
> > +
> > +    def test_split_with_carriage_returns(self):
> > +        self.assertEqual(['foo\rbar\n'],
> > +                         osutils.split_lines('foo\rbar\n'))
> 
> 
> Would be good to also test we can split '', '\n', etc.

I'll add a couple of obvious cases, but I'm not really focused on
documenting the existing api with tests :).

Rob

-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060420/822e481e/attachment.pgp 


More information about the bazaar mailing list