[PATCH default-tests-fix] test: protect the run-tests.py --json test behind an hghave rule

Augie Fackler raf at durin42.com
Tue Sep 23 13:09:59 CDT 2014


On Fri, Sep 19, 2014 at 02:16:17PM +0200, Martin Geisler wrote:
> Pierre-Yves David <pierre-yves.david at ens-lyon.org> writes:
>
> > # HG changeset patch
> > # User Pierre-Yves David <pierre-yves.david at fb.com>
> > # Date 1411065827 25200
> > #      Thu Sep 18 11:43:47 2014 -0700
> > # Node ID fa5cfb6d0b03d9fd471b920d9f5fe0ac358cdbb1
> > # Parent  48791c2bea1ceda4e4f28bc11651e281d636ce1a
> > test: protect the run-tests.py --json test behind an hghave rule
> >
> > We add a rules to detect availability of a json module and skip if json is not
> > available.
> >
> > diff --git a/tests/hghave.py b/tests/hghave.py
> > --- a/tests/hghave.py
> > +++ b/tests/hghave.py
> > @@ -279,10 +279,22 @@ def has_pygments():
> >
> >  @check("python243", "python >= 2.4.3")
> >  def has_python243():
> >      return sys.version_info >= (2, 4, 3)
> >
> > + at check("json", "some json module available")
> > +def has_json():
> > +    try:
> > +        if sys.version_info < (2, 7):
> > +            import simplejson as json
>
> Should this not test with Python 2.6 instead? That was the first version
> that shipped with a json stdlib module:
>
>   https://docs.python.org/2/whatsnew/2.6.html#the-json-module-javascript-object-notation

It'd probably be even better to just do

try:
  import json
except ImportError:
  try:
    import simplejson as json
  except ImportError:
    return False
return True

so that then if someone has a backported json module in 2.5 or
whatever, things Just Work.

>
> --
> Martin Geisler
>
> http://google.com/+MartinGeisler



> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list