Esempio n. 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))
Esempio n. 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))
Esempio n. 3
0
def test_sshash_uses_hash_method():
    class foo(object):
        def __hash__(self):
            return 27

    f = foo()
    assert_equal(sshash(f), 27)
Esempio n. 4
0
def test_sshash_uses_hash_method():
    class foo(object):
        def __hash__(self):
            return 27

    f = foo()
    assert_equal(sshash(f), 27)
Esempio n. 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)
Esempio n. 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))
Esempio n. 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))
Esempio n. 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 )
Esempio n. 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.))
Esempio n. 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))
Esempio n. 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))
Esempio n. 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))
Esempio n. 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))
Esempio n. 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))
Esempio n. 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))
Esempio n. 16
0
def test_sshash_different_lists_different_results():
    a = [1, 2, 3]
    b = [1, 2, 4]
    assert_not_equal(sshash(a), sshash(b))
Esempio n. 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))
Esempio n. 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))
Esempio n. 19
0
def test_sshash_different_lists_different_results():
    a = [1, 2, 3]
    b = [1, 2, 4]
    assert_not_equal(sshash(a), sshash(b))
Esempio n. 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))
Esempio n. 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))
Esempio n. 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))
Esempio n. 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))
Esempio n. 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))
Esempio n. 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))
Esempio n. 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.))