Пример #1
0
def test_get_unique_values_02():
    # non unique
    assert (lambda x, y: len(x) == len(y) and set(x) == y)(
        exam.get_unique_values({
            1: 1,
            2: 1,
            3: 1
        }), {1})
    assert (lambda x, y: len(x) == len(y) and set(x) == y)(
        exam.get_unique_values({
            1: "a",
            2: "a",
            3: "a"
        }), {"a"})
Пример #2
0
def test_get_unique_values_03():
    # various
    assert (lambda x, y: len(x) == len(y) and set(x) == y)(
        exam.get_unique_values({
            1: 1 + 2j,
            2: 1,
            3: 2
        }), {1 + 2j, 1, 2})
    assert (lambda x, y: len(x) == len(y) and set(x) == y)(
        exam.get_unique_values({
            1: -1,
            1182: -1,
            -100: -1
        }), {-1})
Пример #3
0
def test_get_unique_values_01():
    # all unique
    assert (lambda x, y: len(x) == len(y) and set(x) == y)(
        exam.get_unique_values({
            1: 1,
            2: 2,
            3: 3
        }), {1, 2, 3})
    assert (lambda x, y: len(x) == len(y) and set(x) == y)(
        exam.get_unique_values({
            1: "a",
            "d": "b",
            3.2: "c"
        }), {"a", "b", "c"})
Пример #4
0
def test_get_unique_values_05():
    # random
    for _ in range(100):
        dictionary = {}
        for i in range(100):
            dictionary[i] = "".join(
                random.choices(string.ascii_letters, k=random.randint(1, 3)))
        solution = set([x for x in dictionary.values()])
        assert (lambda x, y: len(x) == len(y) and set(x) == y)(
            exam.get_unique_values(dictionary), solution)
Пример #5
0
def test_get_unique_values_04():
    # empty dict
    assert (lambda x, y: len(x) == len(y) and set(x) == y)(
        exam.get_unique_values({}), set())