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 system s, system s uses python unittest2 testing framework (however tweaked). specifically, implements class a, inherits unittest2 , customized exception handling class b. test implemented based on a. system s available on linux only. however, software sf used standalone application, should use unittest2 when test on other platforms, in cases class a 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

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -