Exemplo n.º 1
0
 def test_register(self):
     """ Frames.register should register new FrameSets. """
     name = 'test_frameset'
     fset = FrameSet('abc', name=name)
     Frames.register(fset)
     if getattr(Frames, name, None) is None:
         self.fail(
             self.call_msg(
                 'Failed to register FrameSet attribute.',
                 name,
                 func=Frames.register,
             ))
Exemplo n.º 2
0
def run_frame_name(name,
                   delay=None,
                   char_delay=None,
                   timeout=None,
                   file=sys.stdout):
    """ Run a single animated progress FrameSet by name. """
    try:
        frames = Frames.get_by_name(name)
    except ValueError as ex:
        print_err(ex)
        return 1
    p = AnimatedProgress(
        'Testing animated progress: {}'.format(frames.name),
        frames=frames,
        delay=delay,
        char_delay=char_delay,
        show_time=True,
        timeout=timeout,
        file=file,
    )
    try:
        p.start()
        framelen = len(frames)
        minruntime = 2
        runtime = max((p.delay * framelen) * 2, minruntime)
        sleep(runtime)
        p.stop()
    except ProgressTimedOut as ex:
        print_err('\n{}'.format(ex))
        return 1
    return 0
Exemplo n.º 3
0
 def test_names(self):
     """ Frames.names() sould return a non-empty list of names. """
     names = Frames.names()
     nameslen = len(names)
     self.assertCallNotEqual(
         nameslen,
         0,
         func=len,
         args=(names),
         msg='Frames.names() returned an empty list.',
     )
Exemplo n.º 4
0
 def test_get_by_name(self):
     """ Frames.get_by_name() should return known FrameSets. """
     for name in ('dots', 'dots_blue', 'dots_chase_lightred'):
         try:
             dots = Frames.get_by_name(name)
         except ValueError:
             self.fail(
                 self.call_msg(
                     'Failed to get known name.',
                     name,
                     func=Frames.get_by_name,
                 ))
         self.assertCallIsInstance(
             dots,
             FrameSet,
             func=Frames.get_by_name,
             args=(name, ),
             msg='Returned non-FrameSet object.',
         )