Ejemplo n.º 1
0
 def valid(passphrase):
     return all_distinct(map(sorted, passphrase.split()))
Ejemplo n.º 2
0
def test_alldistinct_failure5():
    # Changing next method
    with pytest.raises(_hf.CacheNext.EXC_TYP, match=_hf.CacheNext.EXC_MSG):
        all_distinct(_hf.CacheNext(1))
Ejemplo n.º 3
0
 def valid(passphrase):
     return all_distinct(passphrase.split())
Ejemplo n.º 4
0
def test_alldistinct_failure3():
    # Failure when comparing the object to the objects in the list
    with pytest.raises(_hf.FailEqNoHash.EXC_TYP,
                       match=_hf.FailEqNoHash.EXC_MSG):
        all_distinct([[T(1)], _hf.FailEqNoHash()])
Ejemplo n.º 5
0
def test_alldistinct_failure4():
    # Failure (no TypeError) when trying to hash the value
    with pytest.raises(_hf.FailHash.EXC_TYP, match=_hf.FailHash.EXC_MSG):
        all_distinct([T(1), _hf.FailHash()])
Ejemplo n.º 6
0
def test_alldistinct_failure1():
    with pytest.raises(_hf.FailIter.EXC_TYP, match=_hf.FailIter.EXC_MSG):
        all_distinct(_hf.FailIter())
Ejemplo n.º 7
0
def test_alldistinct_failure2():
    # Test that a failing iterator doesn't raise a SystemError
    with pytest.raises(_hf.FailNext.EXC_TYP, match=_hf.FailNext.EXC_MSG):
        all_distinct(_hf.FailNext())
Ejemplo n.º 8
0
def test_alldistinct_unhashable2():
    assert not all_distinct([{T('a'): T(1)}, {T('a'): T(1)}])
Ejemplo n.º 9
0
def test_alldistinct_normal3():
    # generator
    assert all_distinct((i for i in [T(1), T(2), T(3)]))
Ejemplo n.º 10
0
def test_alldistinct_normal2():
    assert not all_distinct([T(1), T(1), T(1)])
Ejemplo n.º 11
0
def test_alldistinct_normal1():
    assert all_distinct([T(1), T(2), T(3)])
Ejemplo n.º 12
0
def test_alldistinct_empty1():
    assert all_distinct([])