changeset 40203:f80f7a67e176

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.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Mon, 08 Oct 2018 10:10:06 +0900
parents 56ea22fa55f0
children 5d50c9ffaebb
files tests/test-hgweb-no-path-info.t tests/test-hgweb-no-request-uri.t tests/test-hgweb-non-interactive.t
diffstat 3 files changed, 10 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-hgweb-no-path-info.t	Fri Oct 12 18:20:17 2018 +0200
+++ b/tests/test-hgweb-no-path-info.t	Mon Oct 08 10:10:06 2018 +0900
@@ -18,11 +18,8 @@
   > 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
@@ -72,11 +69,11 @@
   > 
   > 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
--- a/tests/test-hgweb-no-request-uri.t	Fri Oct 12 18:20:17 2018 +0200
+++ b/tests/test-hgweb-no-request-uri.t	Mon Oct 08 10:10:06 2018 +0900
@@ -18,12 +18,9 @@
   > 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 @@
   > 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
--- a/tests/test-hgweb-non-interactive.t	Fri Oct 12 18:20:17 2018 +0200
+++ b/tests/test-hgweb-non-interactive.t	Mon Oct 08 10:10:06 2018 +0900
@@ -19,9 +19,7 @@
   >     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 @@
   >     'SERVER_PROTOCOL': 'HTTP/1.0'
   > }
   > 
-  > i = hgweb(b'.')
+  > i = hgweb_mod.hgweb(b'.')
   > for c in i(env, startrsp):
   >     pass
   > sys.stdout.flush()