Exemplo n.º 1
0
    Returns None on success, raises exception on failure.'''

    module = __import__(modulename)
    total_tested = 0
    total_failed = 0
    for name in dir(module):
        if name.find('__test__') >= 0:
            if type(module.__dict__[name]) == type(unittest):
                if (module.__dict__[name].func_code.co_argcount) == 0:
                    if verbose:
                        print >> log, 'Testing %s' % name
                    try:
                        total_tested += 1
                        module.__dict__[name]()
                    except Exception, e:
                        total_failed += 1
                        print >> sys.stderr, '%s.%s FAILED' % (modulename, name)
                        traceback.print_exc()
    message = 'Module %s failed %s out of %s unittests.' %\
              (modulename, total_failed, total_tested)
    if total_failed > 0:
        raise TestException(message)
    if verbose:
        print >> log, message
        
def __test__():
    print 'in __test__'

import pretest
pretest.pretest('microtest', 1)
Exemplo n.º 2
0
Arquivo: util.py Projeto: wyolum/mmM
    def update(self, x):
        self.staging[self.count % self.deci] = x
        self.count += 1
        if (self.count % self.deci) == 0:
            filtered, self.z = signal.lfilter(self.taps, 1., self.staging, zi=self.z)
            self.out.append(filtered[-1])

    def __call__(self, x):
        return self.update(x)
    def getLast(self):
        if self.count > self.deci:
            out = self.out[-1]
        else:
            out = self.z[-1]
        return out
    last = property(getLast)

LP_TAPS = get_lowpass_taps(defaults['high_cuttoff_hz'], 
                           defaults['dt'],
                           defaults['n_tap'])
LLP_TAPS = get_lowpass_taps(defaults['low_cuttoff_hz'], 
                            defaults['dt'],
                            defaults['n_tap'])
DELAY_TAPS = numpy.zeros(defaults['n_tap'])
DELAY_TAPS[defaults['n_tap'] // 2] = 1

# get_bandpass_taps()
if defaults['run_unittests']:
  import pretest
  pretest.pretest('util')
Exemplo n.º 3
0
import pretest
if __name__ != '__main__':    # when module imported, NOT run as main script
    pretest.pretest(__name__)
Exemplo n.º 4
0
Arquivo: util.py Projeto: wyolum/mmM
            filtered, self.z = signal.lfilter(self.taps,
                                              1.,
                                              self.staging,
                                              zi=self.z)
            self.out.append(filtered[-1])

    def __call__(self, x):
        return self.update(x)

    def getLast(self):
        if self.count > self.deci:
            out = self.out[-1]
        else:
            out = self.z[-1]
        return out

    last = property(getLast)


LP_TAPS = get_lowpass_taps(defaults['high_cuttoff_hz'], defaults['dt'],
                           defaults['n_tap'])
LLP_TAPS = get_lowpass_taps(defaults['low_cuttoff_hz'], defaults['dt'],
                            defaults['n_tap'])
DELAY_TAPS = numpy.zeros(defaults['n_tap'])
DELAY_TAPS[defaults['n_tap'] // 2] = 1

# get_bandpass_taps()
if defaults['run_unittests']:
    import pretest
    pretest.pretest('util')
Exemplo n.º 5
0
            ax.text(*args, **kw)
        if self.xlabel_dat:
            ax.set_xlabel(*self.xlabel_dat[0], **self.xlabel_dat[1])
        if self.ylabel_dat:
            ax.set_ylabel(*self.ylabel_dat[0], **self.ylabel_dat[1])
        if self.title_dat:
            pass
            # ax.set_title(*self.title_dat[0], **self.title_dat[1])
        # ax.text(.5, .5, self.name, transform=ax.transAxes)
        ax.set_xlim(*self.xlim_args[0], **self.xlim_args[1])
        ax.set_ylim(*self.ylim_args[0], **self.ylim_args[1])

def __LazyAxis__test__():        
    la = LazyAxis('test')
    la.plot(range(10))
    la.fill_between(range(10), range(0, 20, 2), range(10))
    la.xlabel('x')
    la.ylabel('y')
    la.title('title')
    fig = figure()              
    ax = fig.add_subplot(111)
    la.draw_on(ax)

def __LazyAxes__test__():
    la = LazyAxes('testing 1 2 3'.split())
    assert '1' in la
    assert isinstance(la['1'], LazyAxis)

import pretest, lazyaxis
pretest.pretest('lazyaxis') 
def __test__100_002():
    print "Test Range 100 - Valid Inputs to guess the number\n"

    #Initialize the game
    range100()

    get_input("50")
    get_input("50")
    get_input("50")
    get_input("50")
    get_input("50")
    get_input("50")
    get_input("50")

    return


def __test__get_input():
    #get_input("200.0")
    get_input("Low End")
    get_input("High End")
    get_input("300")

#The pretest module is loaded in the test runner
if __name__ != '__main__':
    __running_codeskulptor__ = False
    import pretest
    pretest.pretest(__name__, True)


Exemplo n.º 7
0
    verbose:     If true, print test names as they are executed
    Returns None on success, raises exception on failure.
    '''
    module = __import__(modulename)
    total_tested = 0
    total_failed = 0
    for name in dir(module):
        if '__test__' in name:
            obj = getattr(module, name)
            if (isinstance(obj, types.FunctionType) and
                not obj.func_code.co_argcount):
                if verbose:
                    print>>log, 'Testing %s' % name
                try:
                    total_tested += 1
                    obj()
                except Exception, e:
                    total_failed += 1
                    print>>sys.stderr, '%s.%s FAILED' % (modulename, name)
                    traceback.print_exc()
    message = 'Module %s failed %s out of %s unittests.' % (
               modulename, total_failed, total_tested)
    if total_failed:
        raise TestException(message)
    if verbose:
        print>>log, message
def __test__():
    print 'in __test__'
import pretest
pretest.pretest('microtest', verbose=True)
Exemplo n.º 8
0
    total_tested = 0
    total_failed = 0
    for name in dir(module):
        if name.find('__test__') >= 0:
            if type(module.__dict__[name]) == type(unittest):
                if (module.__dict__[name].func_code.co_argcount) == 0:
                    if verbose:
                        print >> log, 'Testing %s' % name
                    try:
                        total_tested += 1
                        module.__dict__[name]()
                    except Exception, e:
                        total_failed += 1
                        print >> sys.stderr, '%s.%s FAILED' % (modulename,
                                                               name)
                        traceback.print_exc()
    message = 'Module %s failed %s out of %s unittests.' %\
              (modulename, total_failed, total_tested)
    if total_failed > 0:
        raise TestException(message)
    if verbose:
        print >> log, message


def __test__():
    print 'in __test__'


import pretest
pretest.pretest('microtest', 1)