Ejemplo n.º 1
0
def test_testprofile_allow_reassignment():
    """TestProfile: allow_reassignment wrapper works."""
    prof = profile.TestProfile()
    prof.test_list['a'] = utils.Test(['foo'])
    with prof.allow_reassignment:
        prof.test_list['a'] = utils.Test(['bar'])

    nt.ok_(prof.test_list['a'].command == ['bar'])
Ejemplo n.º 2
0
def test_testdict_allow_reassignment():
    """TestDict: allow_reassignment works."""
    test = profile.TestDict()
    test['a'] = utils.Test(['foo'])
    with test.allow_reassignment:
        test['a'] = utils.Test(['bar'])

    nt.ok_(test['a'].command == ['bar'])
Ejemplo n.º 3
0
def test_testdict_key_not_string():
    """TestDict: If key value isn't a string an exception is raised.

    This throws a few different things at the key value and expects an error to
    be raised. It isn't a perfect test, but it was the best I could come up
    with.

    """
    test = profile.TestDict()

    for x in [None, utils.Test(['foo']), ['a'], {'a': 1}]:
        test[x] = utils.Test(['foo'])
Ejemplo n.º 4
0
def test_testprofile_update_test_list():
    """ TestProfile.update() updates TestProfile.test_list """
    profile1 = profile.TestProfile()
    group1 = grouptools.join('group1', 'test1')
    group2 = grouptools.join('group1', 'test2')

    profile1.test_list[group1] = utils.Test(['test1'])


    profile2 = profile.TestProfile()
    profile2.test_list[group1] = utils.Test(['test3'])
    profile2.test_list[group2] = utils.Test(['test2'])

    profile1.update(profile2)

    nt.assert_dict_equal(profile1.test_list, profile2.test_list)
Ejemplo n.º 5
0
def test_testprofile_allow_reassignemnt_stacked():
    """profile.TestDict.allow_reassignment: check stacking cornercase.

    There is an odd corner case in the original (obvious) implmentation of this
    function, If one opens two context managers and then returns from the inner
    one assignment will not be allowed, even though one is still inside the
    first context manager.

    """
    test = profile.TestDict()
    test['a'] = utils.Test(['foo'])
    with test.allow_reassignment:
        with test.allow_reassignment:
            pass
        test['a'] = utils.Test(['bar'])

    nt.ok_(test['a'].command == ['bar'])
Ejemplo n.º 6
0
def test_testprofile_allow_reassignment_with_groupmanager():
    """TestProfile: allow_reassignment wrapper works with groupmanager."""
    testname = grouptools.join('a', 'b')
    prof = profile.TestProfile()
    prof.test_list[testname] = utils.Test(['foo'])
    with prof.allow_reassignment:
        with prof.group_manager(utils.Test, 'a') as g:
            g(['bar'], 'b')

    nt.ok_(prof.test_list[testname].command == ['bar'])
Ejemplo n.º 7
0
def test_testdict_reassignment_lower():
    """TestDict: reassigning a key raises an exception (capitalization is ignored)."""
    test = profile.TestDict()
    test['foo'] = utils.Test(['foo'])
    test['Foo'] = utils.Test(['foo', 'bar'])
Ejemplo n.º 8
0
def test_testdict_reassignment():
    """TestDict: reassigning a key raises an exception."""
    test = profile.TestDict()
    test['foo'] = utils.Test(['foo'])
    test['foo'] = utils.Test(['foo', 'bar'])