test_constants_and_functions.py 699 Bytes
Newer Older
Dean Moldovan's avatar
Dean Moldovan committed
1
2
3
4
5
6
7
8


def test_constants():
    from pybind11_tests import some_constant

    assert some_constant == 14


9
def test_function_overloading():
10
    from pybind11_tests import MyEnum, test_function
Dean Moldovan's avatar
Dean Moldovan committed
11

12
13
    assert test_function() == "test_function()"
    assert test_function(7) == "test_function(7)"
14
15
    assert test_function(MyEnum.EFirstEntry) == "test_function(enum=1)"
    assert test_function(MyEnum.ESecondEntry) == "test_function(enum=2)"
Dean Moldovan's avatar
Dean Moldovan committed
16

17
18
19
    assert test_function(1, 1.0) == "test_function(int, float)"
    assert test_function(2.0, 2) == "test_function(float, int)"

Dean Moldovan's avatar
Dean Moldovan committed
20

21
def test_bytes():
Dean Moldovan's avatar
Dean Moldovan committed
22
23
    from pybind11_tests import return_bytes, print_bytes

24
    assert print_bytes(return_bytes()) == "bytes[1 0 2 0]"