Skip to content
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

Use CXOTIME_NOW environment variable as current time if set #50

Merged
merged 3 commits into from
Feb 8, 2025

Conversation

taldcroft
Copy link
Member

@taldcroft taldcroft commented Jan 26, 2025

Description

This updates the CxoTime class to use CXOTIME_NOW environment variable as current time if it is set. This partners with sot/chandra_time#59 to provide broad support for mocking the current time in Python applications. This can be useful for both testing or running a script reproducibly (as if run at a fixed time).

It also improves a test of CxoTime.NOW to provide more margin for running on a Windows VM with long system delays.

Interface impacts

None.

Testing

Unit tests

  • Mac
(ska3-flight-2025.0rc2) ➜  cxotime git:(cxotime-now-environment-override) git rev-parse --short HEAD
9864220
(ska3-flight-2025.0rc2) ➜  cxotime git:(cxotime-now-environment-override) pytest                    
========================================== test session starts ===========================================
platform darwin -- Python 3.12.8, pytest-8.3.4, pluggy-1.5.0
rootdir: /Volumes/git
configfile: pytest.ini
plugins: doctestplus-1.3.0, anyio-4.7.0, timeout-2.3.1
collected 254 items                                                                                      

cxotime/tests/test_cxotime.py .................................................................... [ 26%]
.................................................................................................. [ 65%]
.........................................................................                          [ 94%]
cxotime/tests/test_cxotime_linspace.py ...............                                             [100%]

========================================== 254 passed in 1.47s ===========================================

Independent check of unit tests by Jean

  • OSX
(ska3) flame:cxotime jean$ git rev-parse HEAD
9864220ab55ec1e27006f31e077a21aee2e01a5c
(ska3) flame:cxotime jean$ pytest
=================================================================== test session starts ====================================================================
platform darwin -- Python 3.12.8, pytest-8.3.4, pluggy-1.5.0
rootdir: /Users/jean/git
configfile: pytest.ini
plugins: anyio-4.7.0, timeout-2.3.1
collected 254 items                                                                                                                                        

cxotime/tests/test_cxotime.py ...................................................................................................................... [ 46%]
.........................................................................................................................                            [ 94%]
cxotime/tests/test_cxotime_linspace.py ...............                                                                                               [100%]

=================================================================== 254 passed in 1.44s

Functional tests

No functional testing.

Base automatically changed from docs-pydata-autoapi to master January 29, 2025 10:56
@jeanconn
Copy link
Contributor

jeanconn commented Feb 7, 2025

I note that google also told me about freezegun https://pypi.org/project/freezegun/0.3.4/ but I think the env var makes sense for most of our testing applications.

@taldcroft taldcroft merged commit 9cd4281 into master Feb 8, 2025
2 checks passed
@taldcroft taldcroft deleted the cxotime-now-environment-override branch February 8, 2025 19:20
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