Beispiel #1
0
def test_NocaseDict_unnamedkeys_getitem(testcase, allow, key):
    """
    Test function for NocaseDict.__getitem__() for unnamed keys
    """

    obj = NocaseDict()

    # This is not a very practical use, but necessary to test the function
    obj.allow_unnamed_keys = True
    obj[key] = 'foo'  # Uses __setitem__()
    obj.allow_unnamed_keys = allow

    # The code to be tested
    _ = obj[key]

    # Ensure that exceptions raised in the remainder of this function
    # are not mistaken as expected exceptions
    assert testcase.exp_exc_types is None
Beispiel #2
0
def test_NocaseDict_unnamedkeys_setitem(testcase, allow, key):
    """
    Test function for NocaseDict.__setitem__() for unnamed keys
    """

    obj = NocaseDict()
    obj.allow_unnamed_keys = allow

    # The code to be tested
    obj[key] = 'foo'

    # Ensure that exceptions raised in the remainder of this function
    # are not mistaken as expected exceptions
    assert testcase.exp_exc_types is None

    assert key in obj  # Uses __contains__()