示例#1
0
def test_one_failure5():
    # Test that a failing iterator doesn't raise a SystemError
    with pytest.raises(_hf.FailNext.EXC_TYP, match=_hf.FailNext.EXC_MSG):
        one(_hf.FailNext(offset=1))
示例#2
0
def test_one_failure6():
    # generator without items
    with pytest.raises(ValueError):
        one(i for i in [])
示例#3
0
def test_one_failure2():
    # empty iterable
    with pytest.raises(ValueError):
        one([])
示例#4
0
def test_one_failure3():
    # more than 1 element
    with pytest.raises(ValueError) as exc:
        one([T(1), T(2)])
    assert "'T(1), T(2)[, ...]'" in str(exc.value)
示例#5
0
def test_one_failure1():
    with pytest.raises(_hf.FailIter.EXC_TYP, match=_hf.FailIter.EXC_MSG):
        one(_hf.FailIter())
示例#6
0
def test_one_normal4():
    # generator with one item
    assert one(i for i in [T(0)]) == T(0)
示例#7
0
def test_one_normal3():
    assert one({T('o'): T(10)}) == T('o')
示例#8
0
def test_one_normal2():
    assert one('a') == 'a'
示例#9
0
def test_one_normal1():
    assert one([T(0)]) == T(0)