Skip to content

Conversation

@hyzyla
Copy link
Contributor

@hyzyla hyzyla commented May 9, 2022

Issue: #39

Implemented logic that updates the approx value of IsNow for every comparison. Other ideas, that I've considered:

  • set the approx value to None and generate now on every comparison. Downside -- hard to make repr
  • set the approx value to the current time on __ini__ and do not use it for comparison. Downside -- repr will be lying.
  • Remove internal state from IsNow and on every compassion create an instance of class DateTime and use it for comparing with other value. More work, so I started from the easiest one.

The downside of my implementation is that the internal state is changing for every comparison, instead of not having a state at all.

@codecov
Copy link

codecov bot commented May 9, 2022

Codecov Report

Merging #40 (4d808a5) into main (2d3c0e5) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main       #40   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           11        11           
  Lines          660       666    +6     
  Branches       167       167           
=========================================
+ Hits           660       666    +6     
Impacted Files Coverage Δ
dirty_equals/_datetime.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2d3c0e5...4d808a5. Read the comment docs.

Copy link
Owner

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, any idea why pypy is failing?

If you can't work it out, feel free to skip those test cases.

@hyzyla
Copy link
Contributor Author

hyzyla commented May 13, 2022

Those tests are failing, I think we need to split tests for DateTime and for IsNow. And execute datetime.now() inside of tests body, not in parameterize place:

@pytest.mark.parameterize(...
        pytest.param(datetime.now().isoformat(), IsNow(iso_string=True), True, id='isnow-str-true'),
        pytest.param(datetime(2000, 1, 1).isoformat(), IsNow(iso_string=True), False, id='isnow-str-different'),
)
def test_is_datetime(...): ...

@samuelcolvin
Copy link
Owner

agreed.

@samuelcolvin samuelcolvin merged commit 593bccc into samuelcolvin:main May 13, 2022
@samuelcolvin
Copy link
Owner

thanks so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants