[Python] What is the correct hypothesis strategy for simple data types

Discussão em 'Python' iniciado por Stack, Agosto 22, 2025.

  1. Stack

    Stack Membro Participativo

    If a variable s is of type string ie. s: str. What is the correct strategy, is it

    @given(s = st.text())


    or

    @given(s = st.one_of(st.text() | st.integers() | st.uuids() | st.booleans() | st.floats()))


    Where different kinds of data types are generated to see if the program can handle them correctly.

    My intuition says it is @given(s = st.text()) to test the program validates correctly for the required data type. The program would invalidate other data types.

    Continue reading...

Compartilhe esta Página