def test_scoped_enum():
    from pybind11_tests import ScopedEnum, test_scoped_enum

    if test_scoped_enum(ScopedEnum.Three) != "ScopedEnum::Three":
        raise AssertionError
    z = ScopedEnum.Two
    if test_scoped_enum(z) != "ScopedEnum::Two":
        raise AssertionError

    # expected TypeError exceptions for scoped enum ==/!= int comparisons
    with pytest.raises(TypeError):
        if z != 2:
            raise AssertionError
    with pytest.raises(TypeError):
        if z == 3:
            raise AssertionError

    # order
    if ScopedEnum.Two >= ScopedEnum.Three:
        raise AssertionError
    if ScopedEnum.Three <= ScopedEnum.Two:
        raise AssertionError
    if ScopedEnum.Two > ScopedEnum.Three:
        raise AssertionError
    if ScopedEnum.Two > ScopedEnum.Two:
        raise AssertionError
    if ScopedEnum.Two < ScopedEnum.Two:
        raise AssertionError
    if ScopedEnum.Three < ScopedEnum.Two:
        raise AssertionError
Beispiel #2
0
def test_scoped_enum():
    from pybind11_tests import ScopedEnum, test_scoped_enum

    assert test_scoped_enum(ScopedEnum.Three) == "ScopedEnum::Three"
    z = ScopedEnum.Two
    assert test_scoped_enum(z) == "ScopedEnum::Two"

    # expected TypeError exceptions for scoped enum ==/!= int comparisons
    with pytest.raises(TypeError):
        assert z == 2
    with pytest.raises(TypeError):
        assert z != 3
Beispiel #3
0
def test_scoped_enum():
    from pybind11_tests import ScopedEnum, test_scoped_enum

    assert test_scoped_enum(ScopedEnum.Three) == "ScopedEnum::Three"
    z = ScopedEnum.Two
    assert test_scoped_enum(z) == "ScopedEnum::Two"

    # expected TypeError exceptions for scoped enum ==/!= int comparisons
    with pytest.raises(TypeError):
        assert z == 2
    with pytest.raises(TypeError):
        assert z != 3