Exemplo n.º 1
0
 def test_invalid_var_format_1(self):
     ctx = Context()
     ctx.addVariable("a", "1")
     try:
         res = ctx.getFormated("${a")
     except:
         pass
     else:
         self.fail("Can't fail if invalid format")
Exemplo n.º 2
0
def run( test, verify ):

    conf    = { 'size' : ( 128, 128 ) }
    context = Context.create_root( conf )

    pygame.init()

    screen = pygame.display.set_mode(
        context.conf[ 'size' ],
        0,
        context.conf[ 'depth' ]
    )

    screen.fill( ( 255, 255, 0 ) )

    layer = Layer( context )

    #layer.surface.fill( ( 0, 0, 255 ) )
    #layer.blit( screen )

    loops = 10
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                break
        if loops <= 0:
            break
        loops -= 1
        pygame.time.wait( 50 )

    pygame.quit()

    return True
Exemplo n.º 3
0
def run( test, verify ):

    # create a root context
    context = Context.create_root()

    # tests a single, root context

    depth = context.conf.get( 'depth', 'failed' )
    if depth == 'failed':
        print( 'Configuration resolution failure.' )
        return False

    fgc = context.styles.get( 'foreground-color', 'failed' )
    if fgc == 'failed':
        print( 'Style resolution failure.' )
        return False

    # create a child context

    child = context.create()

    depth = child.conf.get( 'depth', 'failed' )
    if depth == 'failed':
        print( 'Child configuration resolution failure.' )
        return False

    # tests a grandchild context

    grandchild = child.create()

    depth = grandchild.conf.get( 'depth', 'failed' )
    if depth == 'failed':
        print( 'Grandchild configuration resolution failure.' )
        return False

    return True
Exemplo n.º 4
0
 def test_add_variable(self):
     ctx = Context()
     ctx.addVariable("currentDir", "1")
     res = ctx.getFormated("a/${currentDir}/b")
     self.assertEqual(res, "a/1/b")
Exemplo n.º 5
0
    def test_parent_context(self):
        rootCtx = Context()
        rootCtx.addVariable("a", "1")

        childCtx = Context()
        childCtx.addVariable("b", "2")

        childCtx.setParentContext(rootCtx)
        self.assertEqual(childCtx.getVariable("a"), "1")
Exemplo n.º 6
0
 def test_update_list_for_step(self):
     ctx = Context()
     ctx.addVariable("a", "a")
     data = {"a": ["${a}"]}
     res = ctx.createStepNode(data)
     self.assertEqual(res["a"][0], "a")
Exemplo n.º 7
0
 def test_add_varible_format(self):
     ctx = Context()
     ctx.addVariable("a", "a")
     ctx.addVariable("b", "${a}/b")
     res = ctx.getFormated("${b}/c")
     self.assertEqual(res, "a/b/c")
Exemplo n.º 8
0
 def test_add_two_variable(self):
     ctx = Context()
     ctx.addVariable("a", "linux")
     ctx.addVariable("b", "release")
     res = ctx.getFormated("${a}/${b}")
     self.assertEqual(res, "linux/release")
Exemplo n.º 9
0
 def test_readd_variable(self):
     ctx = Context()
     ctx.addVariable("currentDir", "1")
     ctx.addVariable("currentDir", "2")
     res = ctx.getFormated("${currentDir}")
     self.assertEqual(res, "2")