I wasn't aware of the fact that many contributors to sage are users in the first place, and contributors second. So they are probably more familiar with sage's doctests than with unittests. That's good input, thanks!
For me, it's actually the converse: I didn't know what doctests are, but was familiar with the concept of unit tests. What do you think about recommending both ways to write unit tests (as doctest-like TESTS, and unittest python files in src/sage/tests) in the developer documentation, to help onboarding of developers from the broader python community? (Keeping the requirement that methods need to have doctests using the EXAMPLES tag.) As for the advantages of unittests over doctests (given my limited experience with the latter): - Can easily run and debug single tests - Get full intellisense and linting support for writing tests - Easily share common initialization / teardown code between tests - Stronger assertions not only relying on string-comparisons - Supports generation of tests based on (external) data, e.g. if you want to test a method against a range of input -> output pairs - Ability to mock external objects and services (web resources, libraries etc) and use dependency injection - Test code can rely on additional libraries and other code, that doesn't need to be shipped On Saturday, September 5, 2020 at 7:45:53 PM UTC+2 Nils Bruin wrote: > On Friday, September 4, 2020 at 11:18:18 AM UTC-7, tobia...@gmx.de wrote: >> >> Thanks for the quick answers. It's good to know that sage does have a >> distinction between classical doctests and unit tests. Is there a deeper >> reason than tradition that the latter is implemented as doc tests using >> TESTS, instead of more conventional approaches using pytest or nose? Refs >> https://trac.sagemath.org/ticket/28936 >> >> I think an important reason is that a lot of authors don't know what unit > tests are or what is desirable in writing them, but everybody can easily > understand what doctests are. It's easy to see examples of them, because > they're right there with the code. So, the threshold for writing doctests > is much lower. Some test coverage is much better than none, so requiring > people to contribute tests with the lowest threshold method probably gives > us most benefit (in getting tests while not scaring away contributors). > -- 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/b830ad7a-e2b9-4f20-b9b6-d9126dad0090n%40googlegroups.com.