On 07/09/2020 17:13,
Tobia...@gmx.de wrote:
> 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
I would find it useful. Better yet, is having an editor keybinding to