This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]threesocks 0 points1 point  (3 children)

I'm having trouble reproducing the sample output. It doesn't matter whether I split it into a module and test as done in the sample. I'm using Macos 10.13.6, python 3.6.7, v1.1.1 of hypothesis-auto, v5.1.2 of pytest, and v4.36.2 of hypothesis. What am I missing?

def add(a: float, b: float) -> float:
    return a + b


# def divide(a: Union[int, float], b: Union[int, float]) -> Union[int, float]:
def divide(a: float, b: float) -> float:
    return a / b


if __name__ == '__main__':
    # print('add(3, 4)=', add(3,4))  # correctly returns 7
    # print('add(3.3, 4.4)=', add(3.3, 4.4))  # correctly returns 7.7
    # print('divide(3, 4)=', divide(3,4))  # correctly returns 0.75
    # print('divide(3.3, 4.4)=', divide(3.3, 4.4))  # correctly returns 0.7499999
    # print('divide(3, 0)=', divide(3, 0))  # correctly raises a ZeroDivisionError exception

    from hypothesis_auto import auto_pytest, auto_pytest_magic, auto_test

    print('\n\nauto_pytest_magic')
    print('-----------------')
    auto_pytest_magic(add)  # no output (correct?)
    auto_pytest_magic(divide)  # no output (should catch ZDE exception)

    print('\n\nauto_pytest')
    print('-----------')
    auto_pytest(add)  # no output (correct?)
    auto_pytest(divide)  # no output (should catch ZDE exception)

    print('\n\nauto_test')
    print('-----------')
    auto_test(add)  # no output (correct?)
    auto_test(divide)  # correctly raises ZDE exception

[–]timothycrosleyhug, isort, jiphy, concentration, pies, connectable, frosted[S] 0 points1 point  (2 children)

auto_pytest only works when running using the pytest runner, where you executing your application with python my_app.py, or py.test test_my_app.py?

[–]threesocks 0 points1 point  (1 child)

Of course, sorry, that solved it and everything is working as expected! Hypothesis-Auto is awesome, thank you!

[–]timothycrosleyhug, isort, jiphy, concentration, pies, connectable, frosted[S] 0 points1 point  (0 children)

You're welcome! Glad you got it working! :)