test: encapsulate periods module#1138
Conversation
804a3cd to
24cafc0
Compare
MattiSG
left a comment
There was a problem hiding this comment.
Thank you for these contributions! I still don't understand how to validate doctests, and I suffered a lot from trying to set them straight (cf. #1134). I see here that we in the end ignore errors for the “periods” module. If that is indeed the case, then could you help me understand what is the point of “fixing” those tests? 🙂
|
In order to ease future reviews, when you open a PR that depends on another one, could you please make it explicit in the description? 🙂 This will make it easier to review 😊 |
Hi. Actually this PR make periods' doctest run (that's how I fixed them), so for them to be part of the test suite. What is ignored, at least for now, are tests' type checks, that's it. Doctests are valuable in that they're the rare expression of unit tests in this library, coming from the contributors who gave birth to much the codebase. |
583cedd to
57b74ca
Compare
|
Hello @MattiSG ! I hope to have addressed all of your concerns. I have also updated the description to make it clear that this PR only addresses "tests", including those in the docstrings (doctests). |
22457c5 to
9d1c0c8
Compare
a12d131 to
bc9e1aa
Compare
MattiSG
left a comment
There was a problem hiding this comment.
I cannot review this as it depends on #1141 that is disputed, and I don't support changing so many dependencies in an untestable way (cf. #1140 (comment)).
In order to ease reviews, could you please avoid force pushing once the PR has been opened, and rely instead on fixup commits if necessary? 🙂 Otherwise, I cannot rely on GitHub’s presentation of what has “changed since last review”, forcing me to spend time reviewing the same changeset again.
Understood.
OK. |
|
@MattiSG I've had cleanup as much as I can. IMHO both readability and test coverage have improved, which is a triple win:
|
80c4880 to
3a36901
Compare
3a36901 to
1dc83c9
Compare
f7651d9 to
15a8678
Compare
56daa66 to
bf78dde
Compare
Fixes #1269
Part of #1061
Part of #1062
Part of #1063
Supersedes #1139
Supersedes #1043
Depended upon by #1146
Breaking changes
Renames
periods.period.get_subperiodstoperiods.period.subperiods.Deprecations
INSTANT_PATTERNperiods.isoformat.fromstrinstant_date.periods.instant.date.periods.{unit_weight, unit_weights, key_period_size}.periods.dateunit.periods.intersect.periods.parse_periodstricter.2022-1now fails.periods.period.containsas__contains__.subperiod in periodis now possible.Structural changes
Period.datefrom property to method.period.date()(note the parenthesis).Instant.datefrom property to method.instant.date()(note the parenthesis).period.first_monthorperiod.n_2.period.ago(unit: DateUnit, size: int = 1) -> Period.period.last(unit: DateUnit, size: int = 1) -> Period.period.this(unit: DateUnit) -> Period.providing a perfect hotbed for bugs to breed.
dateunitmodule, whichprovides a single source of truth for all date units.
periods.YEARand the like, there is nothing tochange in your code.
"year"or"ETERNITY"are no longer allowed (infact, date unit are int enums an no longer strings).
Technical changes
openfisca_core.periods.openfisca_core.periodsdoctests.openfisca_core.periods.Bug fixes