Patchwork [1,of,5] tests: fix style issue of importing hgweb in embedded code fragments

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Oct. 12, 2018, 7:48 a.m.
Message ID <46871703ab061d8370eb.1539330523@blacknile>
Download mbox | patch
Permalink /patch/35651/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - Oct. 12, 2018, 7:48 a.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1538961006 -32400
#      Mon Oct 08 10:10:06 2018 +0900
# Node ID 46871703ab061d8370eb1a56c0df3e5d748ae154
# Parent  57500950f40e2903df0e1fe20a3dfab7ad0df3cb
# Available At https://bitbucket.org/foozy/mercurial-wip
#              hg pull https://bitbucket.org/foozy/mercurial-wip -r 46871703ab06
# EXP-Topic tests-fix-import-issues
tests: fix style issue of importing hgweb in embedded code fragments

Some test scripts are excluded in test-check-module-imports.t, because
import-checker.py reports that hgweb and/or hgwebdir of
mercurial.hgweb are not imported in recommended style.

To fix this issues, this patch make python code fragments embedded in
these files import hgweb from mercurial package at first, and refer
hgweb and hgwebdir via imported hgweb.
Yuya Nishihara - Oct. 12, 2018, 8:53 p.m.
On Fri, 12 Oct 2018 09:48:43 +0200, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1538961006 -32400
> #      Mon Oct 08 10:10:06 2018 +0900
> # Node ID 46871703ab061d8370eb1a56c0df3e5d748ae154
> # Parent  57500950f40e2903df0e1fe20a3dfab7ad0df3cb
> # Available At https://bitbucket.org/foozy/mercurial-wip
> #              hg pull https://bitbucket.org/foozy/mercurial-wip -r 46871703ab06
> # EXP-Topic tests-fix-import-issues
> tests: fix style issue of importing hgweb in embedded code fragments

Queued, thanks.

Patch

diff --git a/tests/test-hgweb-no-path-info.t b/tests/test-hgweb-no-path-info.t
--- a/tests/test-hgweb-no-path-info.t
+++ b/tests/test-hgweb-no-path-info.t
@@ -18,11 +18,8 @@  should be used from d74fc8dec2b4 onward 
   > from __future__ import absolute_import
   > import os
   > import sys
-  > from mercurial.hgweb import (
+  > from mercurial import (
   >     hgweb,
-  >     hgwebdir,
-  > )
-  > from mercurial import (
   >     util,
   > )
   > stringio = util.stringio
@@ -64,11 +61,11 @@  should be used from d74fc8dec2b4 onward 
   > 
   > output = stringio()
   > env['QUERY_STRING'] = 'style=atom'
-  > process(hgweb(b'.', name=b'repo'))
+  > process(hgweb.hgweb(b'.', name=b'repo'))
   > 
   > output = stringio()
   > env['QUERY_STRING'] = 'style=raw'
-  > process(hgwebdir({b'repo': b'.'}))
+  > process(hgweb.hgwebdir({b'repo': b'.'}))
   > EOF
   $ "$PYTHON" request.py
   ---- STATUS
diff --git a/tests/test-hgweb-no-request-uri.t b/tests/test-hgweb-no-request-uri.t
--- a/tests/test-hgweb-no-request-uri.t
+++ b/tests/test-hgweb-no-request-uri.t
@@ -18,12 +18,9 @@  should be used from d74fc8dec2b4 onward 
   > from __future__ import absolute_import
   > import os
   > import sys
-  > from mercurial.hgweb import (
-  >     hgweb,
-  >     hgwebdir,
-  > )
   > from mercurial import (
   >     encoding,
+  >     hgweb,
   >     util,
   > )
   > stringio = util.stringio
@@ -65,22 +62,22 @@  should be used from d74fc8dec2b4 onward 
   > output = stringio()
   > env['PATH_INFO'] = '/'
   > env['QUERY_STRING'] = 'style=atom'
-  > process(hgweb(b'.', name = b'repo'))
+  > process(hgweb.hgweb(b'.', name = b'repo'))
   > 
   > output = stringio()
   > env['PATH_INFO'] = '/file/tip/'
   > env['QUERY_STRING'] = 'style=raw'
-  > process(hgweb(b'.', name = b'repo'))
+  > process(hgweb.hgweb(b'.', name = b'repo'))
   > 
   > output = stringio()
   > env['PATH_INFO'] = '/'
   > env['QUERY_STRING'] = 'style=raw'
-  > process(hgwebdir({b'repo': b'.'}))
+  > process(hgweb.hgwebdir({b'repo': b'.'}))
   > 
   > output = stringio()
   > env['PATH_INFO'] = '/repo/file/tip/'
   > env['QUERY_STRING'] = 'style=raw'
-  > process(hgwebdir({b'repo': b'.'}))
+  > process(hgweb.hgwebdir({b'repo': b'.'}))
   > EOF
   $ "$PYTHON" request.py
   ---- STATUS
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
@@ -19,9 +19,7 @@  by the WSGI standard and strictly implem
   >     util,
   > )
   > ui = uimod.ui
-  > from mercurial.hgweb.hgweb_mod import (
-  >     hgweb,
-  > )
+  > from mercurial.hgweb import hgweb_mod
   > stringio = util.stringio
   > 
   > class FileLike(object):
@@ -67,7 +65,7 @@  by the WSGI standard and strictly implem
   >     'SERVER_PROTOCOL': 'HTTP/1.0'
   > }
   > 
-  > i = hgweb(b'.')
+  > i = hgweb_mod.hgweb(b'.')
   > for c in i(env, startrsp):
   >     pass
   > sys.stdout.flush()