Re: [test-API PATCH 6/7] parser: Be more specific on mistakes in case files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/21/2012 08:46 PM, Peter Krempa wrote:
This patch adds an error exception if the specification of the test
module from "repos/" ends with a colon (does not specify the module
name) instead of a meaningless backtrace.
---
  exception.py |   10 ++++++++++
  proxy.py     |    4 ++++
  2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/exception.py b/exception.py
index 1a6d6f1..eeb899a 100644
--- a/exception.py
+++ b/exception.py
@@ -75,6 +75,16 @@ class FileExist(LibvirtException):
  class CaseConfigfileError(LibvirtException):
      code = 210
      message = "Case config file Error"
+    def __init__(self, errorstr=None):
+        self.errorstr = errorstr
+
+    def __str__(self):
+        return repr(self.errorstr)
+
+    def response(self):
+        self.status = {'code':self.code, 'message':"%s:%s" %
+                       (self.message, str(self))}
+        return self.status

         The CaseConfigfileError is the subclass of LibvirtException,
         so we just raise it with specific error string,  we don't need
         to overload its method unless the subclass want different
         action in the method.



  class MissingVariable(LibvirtException):
      code = 210
diff --git a/proxy.py b/proxy.py
index aa34d9a..16d498b 100644
--- a/proxy.py
+++ b/proxy.py
@@ -18,6 +18,8 @@
  # The proxy examines the list of unique test cases, received from the
  # generator and import each test case from appropriate module directory.

+import exception
+

  class Proxy(object):
      """ The Proxy class is used for getting real function call reference """
@@ -86,6 +88,8 @@ class Proxy(object):

          # Import recursively module
          for component in components[1:]:
+            if component=="":
+                raise exception.CaseConfigfileError("Missing module name after \":\"")

         Raising an exception here make parsing stronger, thanks.
         BTW, It's better to use if component == "":

         Guannan Ren

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]