Skip to content

pytest example test_bad_dayofyear() #8

@rmcd-mscb

Description

@rmcd-mscb

Thanks for these level-up webinars! I have a question regarding the example test you constructed for the view() function: test_view_bad_dayofyear(). You discovered that setting a day of year to 1000 raises an IndexError. You then added with pytest.raises(IndexError) to the test and the test passes. So the test checks that the code raises a proper error - is the correct way to think of this test? My tendency then would be to take this one step further and trap for that error in the view function to warn the user? Is that a proper response to the unit testing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions