[MERGE] Shelf 1 / 5: TreeTransform serialization

Aaron Bentley aaron at aaronbentley.com
Tue Oct 21 01:29:20 BST 2008


John Arbash Meinel wrote:
> Aaron Bentley wrote: 
> +    def test_roundtrip_creation(self):
> +        tree = self.make_branch_and_tree('.')
> +        tt, tt2 = self.get_two_previews(tree)
> +        tt.new_file(u'foo\u1234', tt.root, 'bar', 'baz', True)
> +        tt.new_directory('qux', tt.root, 'quxx')
> +        self.reserialize(tt, tt2)
> +        self.assertEqual(3, tt2._id_number)
> +        self.assertEqual({'new-1': u'foo\u1234',
> +                          'new-2': 'qux'}, tt2._new_name)
> 
> ^- Question, is it better to compare the exact contents of attributes
> like "_new_name" or would it be better to do:
> self.assertEqual(tt._new_name, tt2._new_name)

I think that if TT's implementation changed enough that the contents of
these dicts changed, we would want to know about it.  Otherwise, we
might unwittingly create shelves that could not be restored.

> It also seems like you should be asserting that the other dicts are
> empty. Though just having "self.assertEqual(tt, tt2)" might cover that
> best.

If I was going to define __eq__ on TT, I'd expect it to cover
everything-- dicts, files, symlinks, etc.  But I think that's too
heavyweight to provide as an equality operator.

> Also, it seems like it would be good to test non-ascii as part of these
> tests. Either by default, or as a separate test. (Mostly non-ascii
> paths, and possibly symlink target, though that isn't very well
> supported by the rest of bzr)

I do test non-ascii paths.  test_roundtrip_creation creates a file named
u'foo\u1234'.   test_roundtrip_destruction deletes a file with the same
name,  I'm happy to add a test for non-ascii symlink targets, though.

Aaron



More information about the bazaar mailing list