[PATCH 4 of 7 hglib] hglib: make util.cmdbuilder work with bytes (issue4520)

Yuya Nishihara yuya at tcha.org
Thu Mar 26 09:34:10 CDT 2015


On Thu, 26 Mar 2015 14:19:01 +0000, Brett Cannon wrote:
> On Thu, Mar 26, 2015 at 10:01 AM Yuya Nishihara <yuya at tcha.org> wrote:
> 
> > On Wed, 25 Mar 2015 20:39:58 -0400, Brett Cannon wrote:
> > > # HG changeset patch
> > > # User Brett Cannon <brett at python.org>
> > > # Date 1427329317 14400
> > > #      Wed Mar 25 20:21:57 2015 -0400
> > > # Node ID 5efe91a4c2d49d74d1104edd50cd5a82003df4b6
> > > # Parent  6d273d0a51aa24f9c837d67b656467f98f98786d
> > > hglib: make util.cmdbuilder work with bytes (issue4520)
> > >
> > > diff -r 6d273d0a51aa -r 5efe91a4c2d4 hglib/util.py
> > > --- a/hglib/util.py   Wed Mar 25 20:19:09 2015 -0400
> > > +++ b/hglib/util.py   Wed Mar 25 20:21:57 2015 -0400
> > > @@ -103,7 +103,7 @@
> > >          if val is None:
> > >              continue
> > >
> > > -        arg = arg.replace(b('_'), b('-'))
> > > +        arg = b(arg).replace(b('_'), b('-'))
> > >          if arg != b('-'):
> > >              if len(arg) == 1:
> > >                  arg = b('-') + arg
> > > @@ -115,10 +115,13 @@
> > >          elif isinstance(val, list):
> > >              for v in val:
> > >                  cmd.append(arg)
> > > -                cmd.append(str(v))
> > > +                cmd.append(v)
> >
> > Doctest fails here.
> >
> > % python -m doctest hglib/util.py
> > **********************************************************************
> > File "hglib/util.py", line 97, in util.cmdbuilder
> > Failed example:
> >     cmdbuilder('cmd', list=[1, 2])
> > Expected:
> >     ['cmd', '--list', '1', '--list', '2']
> > Got:
> >     ['cmd', '--list', 1, '--list', 2]
> > **********************************************************************
> >
> >
> Are doctests typically used?
> http://mercurial.selenic.com/wiki/ContributingChanges doesn't mention them
> and I would assume that if they were important they would be integrated
> into the test.py script in hglib.

They are integrated. See Makefile.

But, I have no idea how b'' can be handled in doctest on Python 3.

Regards,


More information about the Mercurial-devel mailing list