[PATCH 5 of 8 v2] py3: make tests/md5sum.py use absolute_import

Martijn Pieters mj at zopatista.com
Wed May 18 12:32:16 EDT 2016


On 16 May 2016 at 01:40, Pulkit Goyal <7895pulkit at gmail.com> wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit at gmail.com>
> # Date 1463357804 -19800
> #      Mon May 16 05:46:44 2016 +0530
> # Node ID 9dcbddd3c83de18e7706a1221e41f7c2b491324b
> # Parent  e19bc4f627993bcc30c9e97eeb03620f0f563cc8
> py3: make tests/md5sum.py use absolute_import
>
> diff --git a/tests/md5sum.py b/tests/md5sum.py
> --- a/tests/md5sum.py
> +++ b/tests/md5sum.py
> @@ -6,12 +6,17 @@
>  # of the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2, which is
>  # GPL-compatible.
>
> -import sys, os
> +from __future__ import absolute_import
> +
> +import os
> +import sys
>
>  try:
> -    from hashlib import md5
> +    import hashlib
> +    md5 = hashlib.md5
>  except ImportError:
> -    from md5 import md5
> +    import md5
> +    md5 = md5.md5
>

This is only there to support Python versions < 2.5. Since we dropped
support for anything < 2.6 now, the above could be simplified to:

    from hashlib import md5

>  try:
>      import msvcrt
> diff --git a/tests/test-check-py3-compat.t b/tests/test-check-py3-compat.t
> --- a/tests/test-check-py3-compat.t
> +++ b/tests/test-check-py3-compat.t
> @@ -27,7 +27,6 @@
>    i18n/polib.py not using absolute_import
>    setup.py not using absolute_import
>    tests/heredoctest.py requires print_function
> -  tests/md5sum.py not using absolute_import
>    tests/readlink.py not using absolute_import
>    tests/readlink.py requires print_function
>    tests/run-tests.py not using absolute_import
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel



-- 
Martijn Pieters


More information about the Mercurial-devel mailing list