https://bz.mercurial-scm.org/show_bug.cgi?id=6784

diff --git a/tests/test-clone-cgi.t b/tests/test-clone-cgi.t
--- a/tests/test-clone-cgi.t
+++ b/tests/test-clone-cgi.t
@@ -7,31 +7,29 @@ initialize repository
   $ cd test
   $ echo a > a
   $ hg ci -Ama
   adding a
   $ cd ..
   $ cat >hgweb.cgi <<HGWEB
   > #
   > # An example CGI script to use hgweb, edit as necessary
-  > import cgitb
-  > cgitb.enable()
   > from mercurial import demandimport; demandimport.enable()
   > from mercurial.hgweb import hgweb
   > from mercurial.hgweb import wsgicgi
   > application = hgweb(b"test", b"Empty test repository")
   > wsgicgi.launch(application)
   > HGWEB
   $ chmod 755 hgweb.cgi
 
 try hgweb request
 
   $ . "$TESTDIR/cgienv"
   $ QUERY_STRING="cmd=changegroup&roots=0000000000000000000000000000000000000000"; export QUERY_STRING
-  $ "$PYTHON" hgweb.cgi >page1 2>&1
+  $ "$PYTHON" hgweb.cgi >page1
   $ "$PYTHON" "$TESTDIR/md5sum.py" page1
   1f424bb22ec05c3c6bc866b6e67efe43  page1
 
 make sure headers are sent even when there is no body
 
   $ QUERY_STRING="cmd=listkeys&namespace=nosuchnamespace" "$PYTHON" hgweb.cgi
   Status: 200 Script output follows\r (esc)
   Content-Type: application/mercurial-0.1\r (esc)
diff --git a/tests/test-newcgi.t b/tests/test-newcgi.t
--- a/tests/test-newcgi.t
+++ b/tests/test-newcgi.t
@@ -4,19 +4,16 @@ This tests if CGI files from after d0db3
 before d74fc8dec2b4 still work.
 
   $ hg init test
   $ cat >hgweb.cgi <<HGWEB
   > #!$PYTHON
   > #
   > # An example CGI script to use hgweb, edit as necessary
   > 
-  > import cgitb
-  > cgitb.enable()
-  > 
   > from mercurial import demandimport; demandimport.enable()
   > from mercurial.hgweb import hgweb
   > from mercurial.hgweb import wsgicgi
   > from mercurial.hgweb.request import wsgiapplication
   > 
   > def make_web_app():
   >     return hgweb(b"test", b"Empty test repository")
   > 
@@ -30,19 +27,16 @@ before d74fc8dec2b4 still work.
   > test = test
   > HGWEBDIRCONF
 
   $ cat >hgwebdir.cgi <<HGWEBDIR
   > #!$PYTHON
   > #
   > # An example CGI script to export multiple hgweb repos, edit as necessary
   > 
-  > import cgitb
-  > cgitb.enable()
-  > 
   > from mercurial import demandimport; demandimport.enable()
   > from mercurial.hgweb import hgwebdir
   > from mercurial.hgweb import wsgicgi
   > from mercurial.hgweb.request import wsgiapplication
   > 
   > def make_web_app():
   >     return hgwebdir(b"hgweb.config")
   > 
diff --git a/tests/test-newercgi.t b/tests/test-newercgi.t
--- a/tests/test-newercgi.t
+++ b/tests/test-newercgi.t
@@ -4,19 +4,16 @@ This is a rudimentary test of the CGI fi
 
   $ hg init test
 
   $ cat >hgweb.cgi <<HGWEB
   > #!$PYTHON
   > #
   > # An example CGI script to use hgweb, edit as necessary
   > 
-  > import cgitb
-  > cgitb.enable()
-  > 
   > from mercurial import demandimport; demandimport.enable()
   > from mercurial.hgweb import hgweb
   > from mercurial.hgweb import wsgicgi
   > 
   > application = hgweb(b"test", b"Empty test repository")
   > wsgicgi.launch(application)
   > HGWEB
 
@@ -27,19 +24,16 @@ This is a rudimentary test of the CGI fi
   > test = test
   > HGWEBDIRCONF
 
   $ cat >hgwebdir.cgi <<HGWEBDIR
   > #!$PYTHON
   > #
   > # An example CGI script to export multiple hgweb repos, edit as necessary
   > 
-  > import cgitb
-  > cgitb.enable()
-  > 
   > from mercurial import demandimport; demandimport.enable()
   > from mercurial.hgweb import hgwebdir
   > from mercurial.hgweb import wsgicgi
   > 
   > application = hgwebdir(b"hgweb.config")
   > wsgicgi.launch(application)
   > HGWEBDIR
 
diff --git a/tests/test-oldcgi.t b/tests/test-oldcgi.t
--- a/tests/test-oldcgi.t
+++ b/tests/test-oldcgi.t
@@ -3,19 +3,16 @@
 This tests if CGI files from before d0db3462d568 still work.
 
   $ hg init test
   $ cat >hgweb.cgi <<HGWEB
   > #!"$PYTHON"
   > #
   > # An example CGI script to use hgweb, edit as necessary
   > 
-  > import cgitb, os, sys
-  > cgitb.enable()
-  > 
   > # sys.path.insert(0, "/path/to/python/lib") # if not a system-wide install
   > from mercurial import hgweb
   > 
   > h = hgweb.hgweb(b"test", b"Empty test repository")
   > h.run()
   > HGWEB
 
   $ chmod 755 hgweb.cgi
@@ -25,19 +22,16 @@ This tests if CGI files from before d0db
   > test = test
   > HGWEBDIRCONF
 
   $ cat >hgwebdir.cgi <<HGWEBDIR
   > #!"$PYTHON"
   > #
   > # An example CGI script to export multiple hgweb repos, edit as necessary
   > 
-  > import cgitb, sys
-  > cgitb.enable()
-  > 
   > # sys.path.insert(0, "/path/to/python/lib") # if not a system-wide install
   > from mercurial import hgweb
   > 
   > # The config file looks like this.  You can have paths to individual
   > # repos, collections of repos in a directory tree, or both.
   > #
   > # [paths]
   > # virtual/path = /real/path
diff --git a/tests/test-push-cgi.t b/tests/test-push-cgi.t
--- a/tests/test-push-cgi.t
+++ b/tests/test-push-cgi.t
@@ -11,18 +11,16 @@ initialize repository
   adding a
   $ echo '[web]' > .hg/hgrc
   $ echo 'allow_push = *' >> .hg/hgrc
   $ echo 'push_ssl = false' >> .hg/hgrc
 
 create hgweb invocation script
 
   $ cat >hgweb.cgi <<HGWEB
-  > import cgitb
-  > cgitb.enable()
   > from mercurial import demandimport; demandimport.enable()
   > from mercurial.hgweb import hgweb
   > from mercurial.hgweb import wsgicgi
   > application = hgweb(b'.', b'test repository')
   > wsgicgi.launch(application)
   > HGWEB
   $ chmod 755 hgweb.cgi
 
