[Pkg-bazaar-commits] ./bzr/unstable r840: - delay import of subprocess module until it's needed.

Martin Pool mbp at sourcefrog.net
Fri Apr 10 08:21:13 UTC 2009


------------------------------------------------------------
revno: 840
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Wed 2005-07-06 14:20:14 +1000
message:
  - delay import of subprocess module until it's needed.
modified:
  bzrlib/selftest/__init__.py
-------------- next part --------------
=== modified file 'bzrlib/selftest/__init__.py'
--- a/bzrlib/selftest/__init__.py	2005-07-06 00:38:13 +0000
+++ b/bzrlib/selftest/__init__.py	2005-07-06 04:20:14 +0000
@@ -17,16 +17,6 @@
 
 from unittest import TestResult, TestCase
 
-try:
-    import shutil
-    from subprocess import call, Popen, PIPE
-except ImportError, e:
-    import sys
-    sys.stderr.write("testbzr: sorry, this test suite requires the subprocess module\n"
-                     "this is shipped with python2.4 and available separately for 2.3\n")
-    raise
-
-
 class CommandFailed(Exception):
     pass
 
@@ -69,6 +59,16 @@
         If a single string is based, it is split into words.
         For commands that are not simple space-separated words, please
         pass a list instead."""
+        try:
+            import shutil
+            from subprocess import call
+        except ImportError, e:
+            import sys
+            sys.stderr.write("testbzr: sorry, this test suite requires the subprocess module\n"
+                             "this is shipped with python2.4 and available separately for 2.3\n")
+            raise
+
+
         cmd = self.formcmd(cmd)
 
         self.log('$ ' + ' '.join(cmd))
@@ -81,6 +81,16 @@
 
     def backtick(self, cmd, retcode=0):
         """Run a command and return its output"""
+        try:
+            import shutil
+            from subprocess import Popen, PIPE
+        except ImportError, e:
+            import sys
+            sys.stderr.write("testbzr: sorry, this test suite requires the subprocess module\n"
+                             "this is shipped with python2.4 and available separately for 2.3\n")
+            raise
+
+
         cmd = self.formcmd(cmd)
         child = Popen(cmd, stdout=PIPE, stderr=self.TEST_LOG)
         outd, errd = child.communicate()



More information about the Pkg-bazaar-commits mailing list