Пример #1
0
def test_sshash_equal_user_defined_types_equal_results():
    class foo(object):
        def __init__(self, a):
            self.a = a
    f1 = foo(5)
    f2 = foo(7)
    assert_not_equal(sshash(f1), sshash(f2))
Пример #2
0
def test_sshash_equal_user_defined_types_equal_results():
    class foo(object):
        def __init__(self, a):
            self.a = a

    f1 = foo(5)
    f2 = foo(7)
    assert_not_equal(sshash(f1), sshash(f2))
Пример #3
0
def test_sshash_uses_hash_method():
    class foo(object):
        def __hash__(self):
            return 27

    f = foo()
    assert_equal(sshash(f), 27)
Пример #4
0
def test_sshash_uses_hash_method():
    class foo(object):
        def __hash__(self):
            return 27

    f = foo()
    assert_equal(sshash(f), 27)
Пример #5
0
def test_sshash_returns_int():
    for o in [
            0, 1.0, 15L, "foo", (1, 2, 3), None, [1, 2, 3], {
                'a': 3,
                'b': 5
            }
    ]:
        assert_equal(type(sshash(o)), int)
Пример #6
0
def test_sshash_int_and_float_matches():
    assert_equal(sshash(1.), sshash(1))
    assert_equal(sshash(-1.), sshash(-1))
    assert_equal(sshash(16.), sshash(16))
    assert_equal(sshash(10000.), sshash(10000))
Пример #7
0
def test_sshash_different_shape_nparrays_different_results():
    a = np.arange(12).reshape(3,4)
    b = np.arange(12).reshape(4,3)
    assert_not_equal(sshash(a), sshash(b))
Пример #8
0
def test_sshash_returns_int():
    for o in [0, 1.0, 15L, "foo", (1,2,3), None, [1, 2, 3], {'a' : 3, 'b' : 5}]:
        assert_equal(type(sshash(o)), int )
Пример #9
0
def test_sshash_distinct_float_hashes():
    assert_not_equal(sshash(1.), sshash(2.))
    assert_not_equal(sshash(-1.), sshash(1.))
    assert_not_equal(sshash(0.), sshash(1.))
    assert_not_equal(sshash(1000.), sshash(1001.))
    assert_not_equal(sshash(.0001), sshash(0.))
Пример #10
0
def test_sshash_distinct_int_hashes():
    assert_not_equal(sshash(1), sshash(2))
    assert_not_equal(sshash(-1), sshash(1))
    assert_not_equal(sshash(0), sshash(1))
    assert_not_equal(sshash(1000), sshash(1001))
Пример #11
0
def test_sshash_int_and_float_matches():
    assert_equal(sshash(1.), sshash(1))
    assert_equal(sshash(-1.), sshash(-1))
    assert_equal(sshash(16.), sshash(16))
    assert_equal(sshash(10000.), sshash(10000))
Пример #12
0
def test_sshash_equal_dicts_equal_results():
    a = {'a': 1, 'b': 2, 'c': 3}
    b = {'a': 1, 'b': 2, 'c': 3}
    assert_not_equal(id(a), id(b))
    assert_equal(sshash(a), sshash(b))
Пример #13
0
def test_sshash_equal_lists_equal_results():
    a = [1, 2, 3]
    b = [1, 2, 3]
    assert_not_equal(id(a), id(b))
    assert_equal(sshash(a), sshash(b))
Пример #14
0
def test_sshash_equal_lists_equal_results():
    a = [1, 2, 3]
    b = [1, 2, 3]
    assert_not_equal(id(a), id(b))
    assert_equal(sshash(a), sshash(b))
Пример #15
0
def test_sshash_equal_nparrays_equal_results():
    a = np.arange(12).reshape(3,4)
    b = np.arange(12).reshape(3,4)
    assert_equal(sshash(a), sshash(b))
Пример #16
0
def test_sshash_different_lists_different_results():
    a = [1, 2, 3]
    b = [1, 2, 4]
    assert_not_equal(sshash(a), sshash(b))
Пример #17
0
def test_sshash_different_dicts_different_results():
    a = {'a':1, 'b':2, 'c':3}
    b = {'a':1, 'b':7, 'c':3}
    assert_not_equal(sshash(a), sshash(b))
Пример #18
0
def test_sshash_equal_dicts_equal_results():
    a = {'a':1, 'b':2, 'c':3}
    b = {'a':1, 'b':2, 'c':3}
    assert_not_equal(id(a), id(b))
    assert_equal(sshash(a), sshash(b))
Пример #19
0
def test_sshash_different_lists_different_results():
    a = [1, 2, 3]
    b = [1, 2, 4]
    assert_not_equal(sshash(a), sshash(b))
Пример #20
0
def test_sshash_distinct_int_hashes():
    assert_not_equal(sshash(1), sshash(2))
    assert_not_equal(sshash(-1), sshash(1))
    assert_not_equal(sshash(0), sshash(1))
    assert_not_equal(sshash(1000), sshash(1001))
Пример #21
0
def test_sshash_different_dicts_different_results():
    a = {'a': 1, 'b': 2, 'c': 3}
    b = {'a': 1, 'b': 7, 'c': 3}
    assert_not_equal(sshash(a), sshash(b))
Пример #22
0
def test_sshash_different_type_nparrays_different_results():
    a = np.arange(12, dtype=np.uint8).reshape(3,4)
    b = np.arange(12, dtype=np.uint16).reshape(3,4)
    assert_not_equal(sshash(a), sshash(b))
Пример #23
0
def test_sshash_equal_nparrays_equal_results():
    a = np.arange(12).reshape(3, 4)
    b = np.arange(12).reshape(3, 4)
    assert_equal(sshash(a), sshash(b))
Пример #24
0
def test_sshash_different_type_nparrays_different_results():
    a = np.arange(12, dtype=np.uint8).reshape(3, 4)
    b = np.arange(12, dtype=np.uint16).reshape(3, 4)
    assert_not_equal(sshash(a), sshash(b))
Пример #25
0
def test_sshash_different_shape_nparrays_different_results():
    a = np.arange(12).reshape(3, 4)
    b = np.arange(12).reshape(4, 3)
    assert_not_equal(sshash(a), sshash(b))
Пример #26
0
def test_sshash_distinct_float_hashes():
    assert_not_equal(sshash(1.), sshash(2.))
    assert_not_equal(sshash(-1.), sshash(1.))
    assert_not_equal(sshash(0.), sshash(1.))
    assert_not_equal(sshash(1000.), sshash(1001.))
    assert_not_equal(sshash(.0001), sshash(0.))