Patchwork [3,of,5] py3: use absolute_import in test-hgweb-non-interactive.t

login
register
mail settings
Submitter timeless@mozdev.org
Date April 10, 2016, 9:57 p.m.
Message ID <90c4f3e3c85747e09aa7.1460325456@waste.org>
Download mbox | patch
Permalink /patch/14494/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

timeless@mozdev.org - April 10, 2016, 9:57 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1460323925 0
#      Sun Apr 10 21:32:05 2016 +0000
# Node ID 90c4f3e3c85747e09aa7edaedb11c7e556cc8def
# Parent  dcd13c34d6ae90f9f08b9d4c856c17d7bac6fe18
py3: use absolute_import in test-hgweb-non-interactive.t
Yuya Nishihara - April 11, 2016, 2:44 p.m.
On Sun, 10 Apr 2016 16:57:36 -0500, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1460323925 0
> #      Sun Apr 10 21:32:05 2016 +0000
> # Node ID 90c4f3e3c85747e09aa7edaedb11c7e556cc8def
> # Parent  dcd13c34d6ae90f9f08b9d4c856c17d7bac6fe18
> py3: use absolute_import in test-hgweb-non-interactive.t
> 
> diff --git a/tests/test-hgweb-non-interactive.t b/tests/test-hgweb-non-interactive.t
> --- a/tests/test-hgweb-non-interactive.t
> +++ b/tests/test-hgweb-non-interactive.t
> @@ -7,12 +7,19 @@
>    $ hg add bar
>    $ hg commit -m "test"
>    $ cat > request.py <<EOF
> -  > from mercurial import dispatch
> -  > from mercurial.hgweb.hgweb_mod import hgweb
> -  > from mercurial.ui import ui
> -  > from mercurial import hg  
> +  > from __future__ import absolute_import
> +  > import os
> +  > import sys
>    > from StringIO import StringIO
> -  > import os, sys  
> +  > from mercurial import (
> +  >     dispatch,
> +  >     hg,
> +  >     ui as uimod,
> +  > )
> +  > ui = uimod.ui

The point of forcing "uimod" alias is that it is very common to shadow "ui"
variable unexpectedly. So we'd better not to alias back to "ui".

> +  > from mercurial.hgweb.hgweb_mod import (
> +  >     hgweb,
> +  > )

This would be warned if inline python codes could be tested by
import-checker.py.

Can you make a follow-up patch? I've queued the whole series since dropping
this would conflict with the last util.stringio patch.

Patch

diff --git a/tests/test-hgweb-non-interactive.t b/tests/test-hgweb-non-interactive.t
--- a/tests/test-hgweb-non-interactive.t
+++ b/tests/test-hgweb-non-interactive.t
@@ -7,12 +7,19 @@ 
   $ hg add bar
   $ hg commit -m "test"
   $ cat > request.py <<EOF
-  > from mercurial import dispatch
-  > from mercurial.hgweb.hgweb_mod import hgweb
-  > from mercurial.ui import ui
-  > from mercurial import hg
+  > from __future__ import absolute_import
+  > import os
+  > import sys
   > from StringIO import StringIO
-  > import os, sys
+  > from mercurial import (
+  >     dispatch,
+  >     hg,
+  >     ui as uimod,
+  > )
+  > ui = uimod.ui
+  > from mercurial.hgweb.hgweb_mod import (
+  >     hgweb,
+  > )
   > 
   > class FileLike(object):
   >     def __init__(self, real):