Skip to content

(TST) Replacing Timestamp.now () in tests. #44501

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

Merged
merged 12 commits into from
Nov 20, 2021

Conversation

Mikhaylov-yv
Copy link
Contributor

@Mikhaylov-yv Mikhaylov-yv commented Nov 17, 2021

Replacing Timestamp.now() in tests.
Left Timestamp.now () in the following tests:

scalar/timestamp/test_timestamp.py:290:        compare(Timestamp.now(), datetime.now())
scalar/timestamp/test_timestamp.py:291:        compare(Timestamp.now("UTC"), datetime.now(timezone("UTC")))
scalar/timestamp/test_timestamp.py:320:        compare(Timestamp.now(), datetime.now())
scalar/timestamp/test_timestamp.py:321:        compare(Timestamp.now("UTC"), datetime.now(tzutc()))
scalar/timestamp/test_constructors.py:480:        ts_from_method = Timestamp.now()
scalar/timestamp/test_constructors.py:484:        ts_from_method_tz = Timestamp.now(tz="US/Eastern")

@pep8speaks
Copy link

pep8speaks commented Nov 17, 2021

Hello @Mikhaylov-yv! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-11-20 18:47:30 UTC

@Mikhaylov-yv Mikhaylov-yv changed the title Replacing Timestamp.now () in tests. (TST) Replacing Timestamp.now () in tests. Nov 17, 2021
Fixture emits fixed Timestamp.now()
"""
return Timestamp(
year=2021, month=1, day=1, hour=12, minute=0, second=0, microsecond=0
Copy link
Member

Choose a reason for hiding this comment

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

Per my previous suggestion, please make these not zero. e.g. 4, 13, 22

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fixed it

@mroeschke
Copy link
Member

Does this cover all the non-intentional cases of now()?

@Mikhaylov-yv
Copy link
Contributor Author

@mroeschke

Does this cover all the non-intentional cases of now()?

Yes it covers all cases.

Where I was in doubt left now()

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

Thanks LGTM. If you're interested in a follow up, you could add a CI check to ensure now is only used in a certain file where now should be explicitly tested.

@Mikhaylov-yv
Copy link
Contributor Author

@mroeschke Oh sure. But I don’t understand how to do it.

@mroeschke mroeschke added this to the 1.4 milestone Nov 19, 2021
@mroeschke mroeschke added Testing pandas testing functions or related to the test suite Datetime Datetime data dtype labels Nov 19, 2021
@mroeschke
Copy link
Member

No problem can you merge master one more time @Mikhaylov-yv ?

@Mikhaylov-yv
Copy link
Contributor Author

@mroeschke yes of course.

@mroeschke mroeschke merged commit 2b8d566 into pandas-dev:master Nov 20, 2021
@mroeschke
Copy link
Member

Thanks @Mikhaylov-yv. CI failures unrelated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants