On 04/03/2012 09:20 PM, Peter Krempa wrote:
This helper exception helps with reporting test errors that
don't
produce a libvirt exception. Eg. comparison of returned and expected
value fails although the api call succeeded.
---
utils/Python/testError.py | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
create mode 100644 utils/Python/testError.py
diff --git a/utils/Python/testError.py b/utils/Python/testError.py
new file mode 100644
index 0000000..8e7c44f
--- /dev/null
+++ b/utils/Python/testError.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+#
+# libvirt-test-API is copyright 2010 Red Hat, Inc.
+#
+# libvirt-test-API is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version. This program is distributed in
+# the hope that it will be useful, but WITHOUT ANY WARRANTY; without
+# even the implied warranties of TITLE, NON-INFRINGEMENT,
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# The GPL text is available in the file COPYING that accompanies this
+# distribution and
at<http://www.gnu.org/licenses>.
+#
+# Filename: testError.py
+# Summary: internal test error exception
+# Description: An exception to signalize test failures that are
+# separate from libvirt errors
+
+class TestError(Exception):
+ def __init__(self, msg=""):
+ self.msg=msg
+
+ def __str__(self):
+ return self.msg
In testcases, return 0 on success, return 1 on failure, raise
exception means something unexpected
happened. If you want to tell failure of testing, the return
value 1 is enough.
There is a file named exception.py in the root of test-API, If
we want to raise an exception to express
unexpected failure of running testcases from the framework's
point of view.
We could add the TestError as a sublcass in it(or remove
redundant error codes in it).
Guannan Ren