Skip to content

How to guide for testing #937

Open
Open

Description

@hamelsmu

A guide that shows how we test notebooks:

  • fastcore.test
  • How to write unit tests in notebooks
  • test flags
  • How to test nbdev_test, and how to interpret the outputs esp if there is a failure
  • Recommendations for style
  • How this may be different than pytest etc

Activity

  1. added
    documentation
    on Aug 26, 2022
  2. self-assigned this
    on Aug 30, 2022
  3. added this to the v.next milestone on Aug 30, 2022
  4. tcapelle commented on Sep 2, 2022

    @tcapelle

    This would be really cool!
    Currently, nbdev_test does not produce any interpretable output, only lists the failing notebooks without the error message (like nbdev1 used to).

  5. seeM commented on Sep 2, 2022

    @seeM
    Contributor

    @tcapelle it’s supposed to print each error and corresponding cell source. I looked into the nb_helpers repo, in case that’s what you’re referring to, and the errors aren’t printed there because the RichLogger class reconfigures the root logger with level=logging.ERROR, and nbdev_test use warning which logs at level WARNING which is lower than ERROR

    cc @hamelsmu @jph00 - maybe we want to change the way we print those errors?

  6. hamelsmu commented on Sep 2, 2022

    @hamelsmu
    ContributorAuthor

    @seeM I thought maybe you set the logging level to error or were in the process of doing that? Or is that for something else?

  7. removed their assignment
    on Sep 3, 2022
  8. seeM commented on Sep 8, 2022

    @seeM
    Contributor

    @tcapelle could you try again with latest master and see if nbdev_test produces interpretable output for you?

  9. seeM commented on Sep 15, 2022

    @seeM
    Contributor

    @hamelsmu do you think this is sufficiently covered in https://nbdev.fast.ai/tutorials/best_practices.html?

  10. hamelsmu commented on Sep 15, 2022

    @hamelsmu
    ContributorAuthor

    No I don't think so, I think we can talk a lot more about tests esp:

    • Difference from pytest (ex: why you don't need fixtures)
    • test flags
    • When to incorporate tests into visible documentation and when not to
  11. tcapelle commented on Oct 4, 2022

    @tcapelle

    Ohh missed this! thanks guys, and I actually figured this out :P

  12. Jacobluke- commented on Nov 14, 2022

    @Jacobluke-

    Hi! I'm very interested in developing a plotting package using nbdev. However, most graphical testing plugins are for IDE development. Do you have any suggestion on graphical testing in notebooks?

  13. seeM commented on Nov 15, 2022

    @seeM
    Contributor

    Sounds interesting @Jacobluke-! I'm not familiar with "graphical testing", could you please share some graphical testing plugins you've enjoyed using?

  14. Jacobluke- commented on Nov 15, 2022

    @Jacobluke-

    Hi @seeM , thanks for your reply.

    Basically "graphical testing" ensures that our package continue to work in a consistent way. The plugin we are using is pytest-mpl, and here is a brief example on how to using this plugin.

  15. hugetim commented on Feb 5, 2023

    @hugetim
    Contributor

    One pitfall I've run into that may be worth addressing in such a guide: when I forget to export functions (or imports), tests will still pass because the non-exported stuff is loaded in the notebook. I guess putting some tests in a separate notebook would guard against this?

  16. jph00 commented on Feb 5, 2023

    @jph00
    Contributor
  17. jph00 commented on Feb 5, 2023

    @jph00
    Contributor
  18. hugetim commented on Feb 5, 2023

    @hugetim
    Contributor

    Right, it is often caught in a test in a separate notebook if it is used elsewhere, but I won't always have exhaustive test coverage elsewhere if I think its tested in the source notebook. To be more specific about the way this has bit me, it's usually a private helper function or global variable defined in the module scope that I forget to #|export, not something that would be directly called from elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentation

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions