-#!/usr/bin/env python
+#!/bin/sh
+"""": # -*-python-*-
+bup_python="$(dirname "$0")/cmd/bup-python"
+exec "$bup_python" "$0" ${1+"$@"}
+"""
+# end of bup preamble
#
# WvTest:
# Copyright (C)2007-2012 Versabanq Innovations Inc. and contributors.
return text
+ def WVMSG(message):
+ ''' Issues a notification. '''
+ return _result(message, traceback.extract_stack()[-3], 'ok')
+
def WVPASS(cond = True):
''' Counts a test failure unless cond is true. '''
return _check(cond, _code())
'''
try:
func(*args, **kwargs)
- except etype, e:
+ except etype as e:
return _check(True, 'EXCEPT(%s)' % _code())
except:
_check(False, 'EXCEPT(%s)' % _code())
else:
return _check(False, 'EXCEPT(%s)' % _code())
+ def wvfailure_count():
+ return _fails
def _check_unfinished():
if _registered:
sys.path = oldpath
+if sys.version_info >= (2,6,0):
+ _relpath = os.path.relpath;
+else:
+ # Implementation for Python 2.5, taken from CPython (tag v2.6,
+ # file Lib/posixpath.py, hg-commit 95fff5a6a276). Update
+ # ./LICENSE When this code is eventually removed.
+ def _relpath(path, start=os.path.curdir):
+ if not path:
+ raise ValueError("no path specified")
+
+ start_list = os.path.abspath(start).split(os.path.sep)
+ path_list = os.path.abspath(path).split(os.path.sep)
+
+ # Work out how much of the filepath is shared by start and path.
+ i = len(os.path.commonprefix([start_list, path_list]))
+
+ rel_list = [os.path.pardir] * (len(start_list)-i) + path_list[i:]
+ if not rel_list:
+ return curdir
+ return os.path.join(*rel_list)
+
+
def _runtest(fname, f):
mod = inspect.getmodule(f)
- relpath = os.path.relpath(mod.__file__, os.getcwd()).replace('.pyc', '.py')
+ relpath = _relpath(mod.__file__, os.getcwd()).replace('.pyc', '.py')
print
print 'Testing "%s" in %s:' % (fname, relpath)
sys.stdout.flush()
try:
_run_in_chdir(os.path.split(mod.__file__)[0], f)
- except Exception, e:
+ except Exception as e:
print
print traceback.format_exc()
tb = sys.exc_info()[2]
import wvtest as _wvtestmod
sys.modules['wvtest'] = _wvtestmod
sys.modules['wvtest.wvtest'] = _wvtestmod
+ wvtest = _wvtestmod
wvtest_main(sys.argv[1:])