Patchwork [4,of,4] py3: adjust expected traceback in test-hook.t

login
register
mail settings
Submitter Denis Laxalde
Date Oct. 18, 2019, 2:52 p.m.
Message ID <1c619a074a1ef5905d52.1571410345@steppe.local>
Download mbox | patch
Permalink /patch/42476/
State New
Headers show

Comments

Denis Laxalde - Oct. 18, 2019, 2:52 p.m.
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1571410286 -7200
#      Fri Oct 18 16:51:26 2019 +0200
# Node ID 1c619a074a1ef5905d5262ca9d669e4c12e73fc2
# Parent  a2e16cda007faf54c2674db8de0eaf30faa15206
py3: adjust expected traceback in test-hook.t

In Python 3, traceback.format_exception() displays the chain of
exceptions so we get extra results from our grep. Also,
ModuleNotFoundError is raised instead of ImportError from Python 3.6.
via Mercurial-devel - Oct. 18, 2019, 6:54 p.m.
Queuing this, thanks.

On Fri, Oct 18, 2019 at 8:01 AM Denis Laxalde <denis@laxalde.org> wrote:

> # HG changeset patch
> # User Denis Laxalde <denis.laxalde@logilab.fr>
> # Date 1571410286 -7200
> #      Fri Oct 18 16:51:26 2019 +0200
> # Node ID 1c619a074a1ef5905d5262ca9d669e4c12e73fc2
> # Parent  a2e16cda007faf54c2674db8de0eaf30faa15206
> py3: adjust expected traceback in test-hook.t
>
> In Python 3, traceback.format_exception() displays the chain of
> exceptions so we get extra results from our grep. Also,
> ModuleNotFoundError is raised instead of ImportError from Python 3.6.
>
> diff --git a/tests/test-hook.t b/tests/test-hook.t
> index 38a960d..c298092 100644
> --- a/tests/test-hook.t
> +++ b/tests/test-hook.t
> @@ -975,9 +975,18 @@ test python hooks
>    Traceback (most recent call last):
>    SyntaxError: * (glob)
>    exception from second failed import attempt:
> +  Traceback (most recent call last): (py3 !)
> +  SyntaxError: * (glob) (py3 !)
>    Traceback (most recent call last):
> -  ImportError: No module named hgext_syntaxerror
> +  ImportError: No module named hgext_syntaxerror (no-py3 !)
> +  ImportError: No module named 'hgext_syntaxerror' (py3 no-py36 !)
> +  ModuleNotFoundError: No module named 'hgext_syntaxerror' (py36 !)
>    Traceback (most recent call last):
> +  SyntaxError: * (glob) (py3 !)
> +  Traceback (most recent call last): (py3 !)
> +  ImportError: No module named 'hgext_syntaxerror' (py3 no-py36 !)
> +  ModuleNotFoundError: No module named 'hgext_syntaxerror' (py36 !)
> +  Traceback (most recent call last): (py3 !)
>    HookLoadError: preoutgoing.syntaxerror hook is invalid: import of
> "syntaxerror" failed (no-py3 !)
>    mercurial.error.HookLoadError: b'preoutgoing.syntaxerror hook is
> invalid: import of "syntaxerror" failed' (py3 !)
>    abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror"
> failed
> @@ -1133,10 +1142,23 @@ make sure --traceback works on hook impo
>    $ hg --traceback commit -ma 2>&1 | egrep
> '^exception|ImportError|ModuleNotFoundError|Traceback|HookLoadError|abort'
>    exception from first failed import attempt:
>    Traceback (most recent call last):
> -  ImportError: No module named somebogusmodule
> +  ImportError: No module named somebogusmodule (no-py3 !)
> +  ImportError: No module named 'somebogusmodule' (py3 no-py36 !)
> +  ModuleNotFoundError: No module named 'somebogusmodule' (py36 !)
>    exception from second failed import attempt:
> +  Traceback (most recent call last): (py3 !)
> +  ImportError: No module named 'somebogusmodule' (py3 no-py36 !)
> +  ModuleNotFoundError: No module named 'somebogusmodule' (py36 !)
> +  Traceback (most recent call last): (py3 !)
> +  ImportError: No module named 'hgext_importfail' (py3 no-py36 !)
> +  ModuleNotFoundError: No module named 'hgext_importfail' (py36 !)
> +  Traceback (most recent call last): (py3 !)
> +  ImportError: No module named 'somebogusmodule' (py3 no-py36 !)
> +  ModuleNotFoundError: No module named 'somebogusmodule' (py36 !)
>    Traceback (most recent call last):
> -  ImportError: No module named hgext_importfail
> +  ImportError: No module named hgext_importfail (no-py3 !)
> +  ImportError: No module named 'hgext_importfail' (py3 no-py36 !)
> +  ModuleNotFoundError: No module named 'hgext_importfail' (py36 !)
>    Traceback (most recent call last):
>    HookLoadError: precommit.importfail hook is invalid: import of
> "importfail" failed (no-py3 !)
>    mercurial.error.HookLoadError: b'precommit.importfail hook is invalid:
> import of "importfail" failed' (py3 !)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/tests/test-hook.t b/tests/test-hook.t
index 38a960d..c298092 100644
--- a/tests/test-hook.t
+++ b/tests/test-hook.t
@@ -975,9 +975,18 @@  test python hooks
   Traceback (most recent call last):
   SyntaxError: * (glob)
   exception from second failed import attempt:
+  Traceback (most recent call last): (py3 !)
+  SyntaxError: * (glob) (py3 !)
   Traceback (most recent call last):
-  ImportError: No module named hgext_syntaxerror
+  ImportError: No module named hgext_syntaxerror (no-py3 !)
+  ImportError: No module named 'hgext_syntaxerror' (py3 no-py36 !)
+  ModuleNotFoundError: No module named 'hgext_syntaxerror' (py36 !)
   Traceback (most recent call last):
+  SyntaxError: * (glob) (py3 !)
+  Traceback (most recent call last): (py3 !)
+  ImportError: No module named 'hgext_syntaxerror' (py3 no-py36 !)
+  ModuleNotFoundError: No module named 'hgext_syntaxerror' (py36 !)
+  Traceback (most recent call last): (py3 !)
   HookLoadError: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed (no-py3 !)
   mercurial.error.HookLoadError: b'preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed' (py3 !)
   abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
@@ -1133,10 +1142,23 @@  make sure --traceback works on hook impo
   $ hg --traceback commit -ma 2>&1 | egrep '^exception|ImportError|ModuleNotFoundError|Traceback|HookLoadError|abort'
   exception from first failed import attempt:
   Traceback (most recent call last):
-  ImportError: No module named somebogusmodule
+  ImportError: No module named somebogusmodule (no-py3 !)
+  ImportError: No module named 'somebogusmodule' (py3 no-py36 !)
+  ModuleNotFoundError: No module named 'somebogusmodule' (py36 !)
   exception from second failed import attempt:
+  Traceback (most recent call last): (py3 !)
+  ImportError: No module named 'somebogusmodule' (py3 no-py36 !)
+  ModuleNotFoundError: No module named 'somebogusmodule' (py36 !)
+  Traceback (most recent call last): (py3 !)
+  ImportError: No module named 'hgext_importfail' (py3 no-py36 !)
+  ModuleNotFoundError: No module named 'hgext_importfail' (py36 !)
+  Traceback (most recent call last): (py3 !)
+  ImportError: No module named 'somebogusmodule' (py3 no-py36 !)
+  ModuleNotFoundError: No module named 'somebogusmodule' (py36 !)
   Traceback (most recent call last):
-  ImportError: No module named hgext_importfail
+  ImportError: No module named hgext_importfail (no-py3 !)
+  ImportError: No module named 'hgext_importfail' (py3 no-py36 !)
+  ModuleNotFoundError: No module named 'hgext_importfail' (py36 !)
   Traceback (most recent call last):
   HookLoadError: precommit.importfail hook is invalid: import of "importfail" failed (no-py3 !)
   mercurial.error.HookLoadError: b'precommit.importfail hook is invalid: import of "importfail" failed' (py3 !)