python - How to use different test package on different platforms -
i come c++ background, python knowledge limited, need following situation:
background:
we have software
sf
, integrated large systems
, systems
uses pythonunittest2
testing framework (however tweaked). specifically, implements classa
, inheritsunittest2
, customized exception handling classb
. test implemented based ona
. systems
available on linux only. however, softwaresf
used standalone application, should useunittest2
when test on other platforms, in cases classa
not available.
question:
how apply different test packages on different platforms?
my possible solution:
thinking of implementing wrapper class based on thread: create wrapper class call pre , post function around existing functions?. answer post put below:
class wrapper(object): def __init__(self,wrapped_class): self.wrapped_class = wrapped_class() def __getattr__(self,attr): orig_attr = self.wrapped_class.__getattribute__(attr) if callable(orig_attr): def hooked(*args, **kwargs): self.pre() result = orig_attr(*args, **kwargs) # prevent wrapped_class becoming unwrapped if result == self.wrapped_class: return self self.post() return result return hooked else: return orig_attr
however, don't think above thread quite relevant since dealing wrappers around class' member functions while want wrapper class wrappers around different testing packages. possible in python? using python 2.7 fyi.
any input appreciated , happy add more information if helps make myself clear. thank you.
Comments
Post a Comment