-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: encapsulate periods module #1138
base: master
Are you sure you want to change the base?
Conversation
804a3cd
to
24cafc0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Yes, of course, this is a good case for #1159. But I want to stress once more that #1159 is not about allowing the use of release candidates, but about allowing replacing code review by extensive testing in some contexts. In the given case, I understand that @benjello says testing on France would be welcome. If you want to simplify that testing by using a release candidate (as opposed to a local clone), sure, do it! No need for #1159 for that 😉 |
openfisca_core/periods/period_.py
Outdated
f"{str(self.unit)}." | ||
) | ||
|
||
def this(self, unit: DateUnit) -> Period: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benjello look from here below, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eraviart What do you think? |
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_subperiods
toperiods.period.subperiods
.Deprecations
INSTANT_PATTERN
periods.isoformat.fromstr
instant_date
.periods.instant.date
.periods.{unit_weight, unit_weights, key_period_size}
.periods.dateunit
.periods.intersect
.periods.parse_period
stricter.2022-1
now fails.periods.period.contains
as__contains__
.subperiod in period
is now possible.Structural changes
Period.date
from property to method.period.date()
(note the parenthesis).Instant.date
from property to method.instant.date()
(note the parenthesis).period.first_month
orperiod.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.
dateunit
module, whichprovides a single source of truth for all date units.
periods.YEAR
and 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.periods
doctests.openfisca_core.periods
.Bug fixes