On Friday, September 4, 2020 at 7:02:27 AM UTC-7, tobia...@gmx.de wrote: > > > Hi everybody, > > I'm currently in the progress of cleaning up my code implementing > symplectic structures in sage. While doing so, I noticed that there are a > lot of doctests in the existing code that test rather elementary things. > These are often not utterly important for a user of the method, but are > rather unit tests that verify the correct behavior in some edge case. For > this reason, I wanted to move these doctests to unittests - where I then > realized that the `tests` folder is almost empty. So obviously I'm missing > something here. > > Finding almost no unit tests in sage made me a bit uncertain, and I did a > bit of research. The general opinion (for example echoed in > https://stackoverflow.com/questions/361675/python-doctest-vs-unittest) > seems to be that doc tests are there to verify that the documentation is > correct (in sync with the implementation) while unit tests make sure that > the code is correct. This also make sense since you usually don't want to > bloat the documentation with edge cases, and IDEs have limited supported > for doctests while unit tests get all the support of normal python code, > including debugging etc. > > So what's the sage convention concerning unit tests vs doctests? >
The Sage convention is to use doctests: EXAMPLES:: sage: test1 output ... To test the code but not (by default) appear in the documentation, use "TESTS" blocks: TESTS:: sage: test2 output ... See https://doc.sagemath.org/html/en/developer/coding_basics.html#documentation-strings, for example. -- John -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/5bdbf05a-2629-4333-9e50-104f719663f5o%40googlegroups.com.