method = getattr(self, name)
method(testcap, testdir = os.path.join(mp, name))
print 'Test succeeded.'
- except self.TestFailure, f:
+ except TestFailure, f:
print f
failures += 1
except:
# Tests:
def test_directory_existence(self, testcap, testdir):
- if not os.path.isdir(testdir):
- raise self.TestFailure('Attached test directory not found: %r', testdir)
+ if not wrap_os_error(os.path.isdir, testdir):
+ raise TestFailure('Attached test directory not found: %r', testdir)
def test_empty_directory_listing(self, testcap, testdir):
listing = os.listdir(testdir)
if listing:
- raise self.TestFailure('Expected empty directory, found: %r', listing)
+ raise TestFailure('Expected empty directory, found: %r', listing)
def test_directory_listing(self, testcap, testdir):
names = []
listing.sort()
if listing != names:
tmpl = 'Expected directory list containing %r but fuse gave %r'
- raise self.TestFailure(tmpl, names, listing)
+ raise TestFailure(tmpl, names, listing)
for file, size in filesizes.items():
st = os.stat(os.path.join(testdir, file))
if st.st_size != size:
tmpl = 'Expected %r size of %r but fuse returned %r'
- raise self.TestFailure(tmpl, file, size, st.st_size)
+ raise TestFailure(tmpl, file, size, st.st_size)
def test_file_contents(self, testcap, testdir):
name = 'hw.txt'
found = open(path, 'r').read()
except Exception, err:
tmpl = 'Could not read file contents of %r: %r'
- raise self.TestFailure(tmpl, path, err)
+ raise TestFailure(tmpl, path, err)
if found != body:
tmpl = 'Expected file contents %r but found %r'
- raise self.TestFailure(tmpl, body, found)
+ raise TestFailure(tmpl, body, found)
# Utilities:
tmpl += 'Command arguments: %r\n'
tmpl += 'Exit status: %r\n'
tmpl += 'Output:\n%s\n[End of tahoe output.]\n'
- raise self.SetupFailure(tmpl,
+ raise SetupFailure(tmpl,
self.cliexec,
realargs,
status,
tmpl += 'Request: %r %r\n'
tmpl += 'Body:\n%s\n'
tmpl += 'Response:\nStatus %r\nBody:\n%s'
- raise self.SetupFailure(tmpl,
+ raise SetupFailure(tmpl,
method, path,
body or '',
resp.status, body)
tmpl = 'Timeout while polling for: %s\n'
tmpl += 'Waited %.2f seconds (%d polls).'
- raise self.SetupFailure(tmpl, polldesc, totaltime, attempt+1)
+ raise SetupFailure(tmpl, polldesc, totaltime, attempt+1)
def warn(self, tmpl, *args):
print ('Test Warning: ' + tmpl) % args
- # SystemTest Exceptions:
- class Failure (Exception):
- def __init__(self, tmpl, *args):
- msg = self.Prefix + (tmpl % args)
- Exception.__init__(self, msg)
+# SystemTest Exceptions:
+class Failure (Exception):
+ def __init__(self, tmpl, *args):
+ msg = self.Prefix + (tmpl % args)
+ Exception.__init__(self, msg)
- class SetupFailure (Failure):
- Prefix = 'Setup Failure - The test framework encountered an error:\n'
+class SetupFailure (Failure):
+ Prefix = 'Setup Failure - The test framework encountered an error:\n'
- class TestFailure (Failure):
- Prefix = 'TestFailure: '
+class TestFailure (Failure):
+ Prefix = 'TestFailure: '
### Unit Tests: