예제 #1
0
def test_dict_hash():
    h1 = dict_hash({"foo": "bar", "bar": "baz"})
    h2 = dict_hash({"foo": "bar", "bar": "baz"})
    assert h1 == h2

    h3 = dict_hash({"egg": "spam"})
    assert h3 != h2
예제 #2
0
def test_dict_hash_nested():
    h1 = dict_hash({"foo": "bar", "bar": {"baz": "spam"}})
    h2 = dict_hash({"foo": "bar", "bar": {"baz": "spam"}})
    assert h1 == h2

    h3 = dict_hash({"foo": "bar", "bar": {"baz": "egg"}})
    h4 = dict_hash({"foo": "bar", "bar": {"bam": "spam"}})
    assert h3 != h2
    assert h4 != h2
예제 #3
0
def test_dict_hash_non_strings():
    h1 = dict_hash({
        "foo": "bar",
        "float": 1.1,
        "int": 2,
        "bool": False,
        "seq": ["x", "y", (2, 3.7, {
            "x": 5,
            "y": [6, 7]
        })]
    })
    h2 = dict_hash({"foo": "bar", "float": 1.2, "int": 2, "bool": False})
    assert h1 != h2
예제 #4
0
def test_dict_hash_invalid():
    with pytest.raises(ValueError):
        dict_hash({"foo": scrapy})
예제 #5
0
def test_dict_hash(val1, val2):
    assume(val1 != val2)
    assert dict_hash(val1) == dict_hash(val1)
    assert dict_hash(val1) != dict_hash(val2)