Country or region and language

    Choose your country or region and your language.

    Suggested for you

      All countries and regions

        Choose your character

        It shows in the top bar and on your profile. Change it any time.

        Sign in or join
        Python for software engineers course

        Parameterized pytest cases

        Opening Python for software engineers
        Your turn

        Parameterized pytest cases

        One table, every boundary

        @pytest.mark.parametrize("value, expected", [...]) runs one test per row. That makes gaps visible: for an inclusive range, put the values just below, on and just above each limit in the same table. Write the expected column by hand. Computing it with the function you are testing copies its bug into the test.

        Names that explain a failure

        pytest.param(..., id="upper-limit") gives a case a name pytest prints when it fails, so a broken rule is easy to find. The parametrize guide covers stacking and indirect parameters. The lesson’s tasks cover an age range, a status policy that uses exact tokens, Decimal half-up rounding and identifier normalization where an empty string is a valid result. Each test module you write is checked against a correct implementation and two faulty ones.

        Guides on this topic

        Your Work Gym account

        Save your progress and pick up on another device. Your browser's progress comes with you.

        Your account can start a 5-day free trial: every course, unit, project and exam. Card needed; cancel any time and pay nothing.

        New accounts get 6 hours of full access: every course, unit, project and exam. The clock starts when you go past the free lessons.

        Plan your practice from a job ad or syllabus

        Have a referral code?

        or

        You can keep practicing without an account.

        Change your plan

        Checking the price

        Help and feedback

        Ask a question, tell us what is not working, or share an idea. We reply by email.

        What is it about?

        We use it only to reply to you.