Skip to content

Improve package's doctests #1061

@bonjourmauko

Description

@bonjourmauko

Hi there!

I really enjoy OpenFisca, but I recently encountered an issue.

Here is what I did:

pytest openfisca_core openfisca_web_api --maxfail 0 --continue-on-collection-errors --quiet

Here is what I expected to happen:

XXX passed, X xfailed, XXX warnings in X.XXs

Here is what actually happened:

========================================================================================= short test summary info ==========================================================================================
FAILED openfisca_core/commons/formulas.py::openfisca_core.commons.formulas.apply_thresholds
FAILED openfisca_core/commons/formulas.py::openfisca_core.commons.formulas.switch
FAILED openfisca_core/holders/holder.py::openfisca_core.holders.holder.Holder.get_memory_usage
...
ERROR openfisca_core/scripts/measure_numpy_condition_notations.py::test_switch_select

Context:

Python provides doctests to help keep a testable documentation.

They provide some benefits:

  • They help maintainers and contributors to spot bugs and improvement opportunities.
  • They helps reusers to understand the code quickly
  • They help separating contexts (unit, functional, ...)
  • They help produce the official doc

Complications:

Today the code coverage by doctests is mild, they are not run, and most of them are broken.

Some observed consequences:

  • The code is in overall hard to grasp without a consequent time investment, thus hard to contribute to
  • The code is hard to test unitarily due to its current design
  • There are then very few unit tests
  • The documentation is was broken

Proposal:

Fix, complete, and run doctests systematically!

TODO

Metadata

Metadata

Assignees

Labels

kind:roadmapA group of issues, constituting a delivery roadmapkind:testAdding missing tests or correcting existing tests

Type

No type

Projects

Status

Roadmaps/Themes

Relationships

None yet

Development

No branches or pull requests

Issue actions