--- /dev/null
+$ python test.py
+**********************************************************************
+File "/home/wking/src/fun/be/libbe/plugin.py", line 31, in libbe.plugin.iter_plugins
+Failed example:
+ "plugin" in [n for n,m in iter_plugins("libbe")]
+Exception raised:
+ Traceback (most recent call last):
+ File "/usr/lib/python2.5/doctest.py", line 1228, in __run
+ compileflags, 1) in test.globs
+ File "<doctest libbe.plugin.iter_plugins[1]>", line 1, in <module>
+ "plugin" in [n for n,m in iter_plugins("libbe")]
+ File "/home/wking/src/fun/be/libbe/plugin.py", line 38, in iter_plugins
+ yield modfile[:-3], my_import(prefix+"."+modfile[:-3])
+ File "/home/wking/src/fun/be/libbe/plugin.py", line 21, in my_import
+ module = __import__(mod_name)
+ File "/home/wking/src/fun/be/libbe/restconvert.py", line 27, in <module>
+ from elementtree import ElementTree
+ ImportError: No module named elementtree
+**********************************************************************
+1 items had failures:
+ 1 of 2 in libbe.plugin.iter_plugins
+***Test Failed*** 1 failures.
+Traceback (most recent call last):
+ File "test.py", line 32, in <module>
+ for module in plugin.iter_plugins("libbe"):
+ File "/home/wking/src/fun/be/libbe/plugin.py", line 38, in iter_plugins
+ yield modfile[:-3], my_import(prefix+"."+modfile[:-3])
+ File "/home/wking/src/fun/be/libbe/plugin.py", line 21, in my_import
+ module = __import__(mod_name)
+ File "/home/wking/src/fun/be/libbe/restconvert.py", line 27, in <module>
+ from elementtree import ElementTree
+ImportError: No module named elementtree
+
+
+Looking into ElementTree, I found their webpage:
+http://effbot.org/zone/element-index.htm
+
+ It’s common practice to import ElementTree under an alias, both to
+ minimize typing, and to make it easier to switch between different
+ implementations:
+
+ $ python
+ >>> import elementtree.ElementTree as ET
+ >>> import cElementTree as ET
+ >>> import lxml.etree as ET
+ >>> import xml.etree.ElementTree as ET # Python 2.5
+
+Using new import style, fall back to old if that fails.
+Affected files:
+ libbe/restconvert.py
+ Bugs-Everywhere-Web/beweb/formatting.py
--- /dev/null
+
+
+
+Content-type=text/plain
+
+
+
+
+
+
+Date=Thu, 13 Nov 2008 17:27:17 +0000
+
+
+
+
+
+
+From=wking
+
+
+
--- /dev/null
+
+
+
+creator=wking
+
+
+
+
+
+
+severity=minor
+
+
+
+
+
+
+status=closed
+
+
+
+
+
+
+summary=elementtree module moved in Python 2.5
+
+
+
+
+
+
+time=Thu, 13 Nov 2008 16:45:24 +0000
+
+
+
--- /dev/null
+Calls to Popen() while running `test.py` raised OSError because of
+missing binaries (tla was not installed). Added catches to produce
+more useful error messages in the backtrace.
--- /dev/null
+
+
+
+Content-type=text/plain
+
+
+
+
+
+
+Date=Thu, 13 Nov 2008 15:58:18 +0000
+
+
+
+
+
+
+From=wking
+
+
+
--- /dev/null
+
+
+
+creator=wking
+
+
+
+
+
+
+severity=minor
+
+
+
+
+
+
+status=closed
+
+
+
+
+
+
+summary=Popen OSErrors not caught
+
+
+
+
+
+
+time=Thu, 13 Nov 2008 15:54:45 +0000
+
+
+
--- /dev/null
+When running `python test.py` I recieved lots of errors due to 'tla'
+(the GNU Arch revision control system binary) not being installed.
+I had expected test.py to only test the backends for installed VCSs.
+
+I've added a note saying that `python test.py` tests *all* the
+backends, but someone who understands the usage better can probably
+write a nicer version.
--- /dev/null
+
+
+
+Content-type=text/plain
+
+
+
+
+
+
+Date=Thu, 13 Nov 2008 16:35:24 +0000
+
+
+
+
+
+
+From=wking
+
+
+
--- /dev/null
+Ideally the tests would fail gracefully with some simple message like
+"tla version control system not found", and we could skip the message
+in the test.py docstring.
--- /dev/null
+
+
+
+Content-type=text/plain
+
+
+
+
+
+
+Date=Thu, 13 Nov 2008 16:38:36 +0000
+
+
+
+
+
+
+From=wking
+
+
+
--- /dev/null
+
+
+
+creator=wking
+
+
+
+
+
+
+severity=minor
+
+
+
+
+
+
+status=open
+
+
+
+
+
+
+summary=Usage of be/test.py is unclear
+
+
+
+
+
+
+time=Thu, 13 Nov 2008 16:31:41 +0000
+
+
+
from StringIO import StringIO
-from elementtree.ElementTree import XML
+try :
+ from xml.etree.ElementTree import XML # Python 2.5 (and greater?)
+except ImportError :
+ from elementtree.ElementTree import XML
from libbe.restconvert import rest_xml
def to_unix(text):
config.set_val("arch_client", client)
def invoke(args):
- q = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
+ try :
+ q = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
+ except OSError, e :
+ strerror = "%s\nwhile executing %s" % (e.args[1], args)
+ raise Exception("Command failed: %s" % strerror)
output = q.stdout.read()
error = q.stderr.read()
status = q.wait()
self.status = status
def invoke(args, expect=(0,), cwd=None):
- if sys.platform != "win32":
- q = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=cwd)
- else:
- # win32 don't have os.execvp() so have to run command in a shell
- q = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True,
- cwd=cwd)
+ try :
+ if sys.platform != "win32":
+ q = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=cwd)
+ else:
+ # win32 don't have os.execvp() so have to run command in a shell
+ q = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True,
+ cwd=cwd)
+ except OSError, e :
+ strerror = "%s\nwhile executing %s" % (e.args[1], args)
+ raise CommandError(strerror, e.args[0])
output, error = q.communicate()
status = q.wait()
if status not in expect:
from docutils.parsers import rst
from docutils.parsers.rst import directives
from docutils.parsers.rst.states import Inliner, MarkupMismatch, unescape
-from elementtree import ElementTree
+try :
+ from xml.etree import ElementTree # Python 2.5 (and greater?)
+except ImportError :
+ from elementtree import ElementTree
def rest_xml(rest):
+"""Usage: python test.py [module]
+
+When called without an optional module name, run the doctests from
+*all* modules. This may raise lots of errors if you haven't installed
+one of the versioning control systems.
+
+When called with an optional module name, only run the doctests from
+that module.
+"""
+
from libbe import plugin
import doctest
import sys