Skip to content

Commit 3e50198

Browse files
Make freezegun optional to pass tests.
1 parent d72c573 commit 3e50198

File tree

6 files changed

+22
-23
lines changed

6 files changed

+22
-23
lines changed

notebooks/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ lint:
1313
ruff check tests
1414

1515
notebook:
16-
TZ=UTC jupyter nbconvert --to notebook --inplace --execute *.ipynb
16+
TZ=UTC FAKE_NOW=True jupyter nbconvert --to notebook --inplace --execute *.ipynb
1717
jupyter nbconvert --to notebook --coalesce-streams --inplace --ClearMetadataPreprocessor.enabled=True --ClearNotebookMetadataPreprocessor.enabled=True *.ipynb
1818

1919
test: test-nb

notebooks/config.ipynb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@
3939
"metadata": {},
4040
"outputs": [],
4141
"source": [
42+
"import os\n",
4243
"from pathlib import Path\n",
4344
"from freezegun import freeze_time\n",
4445
"from uwtools.api import config\n",
4546
"from uwtools.api.logging import use_uwtools_logger\n",
4647
"\n",
47-
"freeze_time(\"2000-01-01 00:00:00 UTC\").start()\n",
48+
"if os.environ.get(\"FAKE_NOW\"):\n",
49+
" freeze_time(\"2000-01-01 00:00:00 UTC\").start()\n",
4850
"\n",
4951
"use_uwtools_logger()"
5052
]
@@ -1547,7 +1549,7 @@
15471549
" | clear(self)\n",
15481550
" | D.clear() -> None. Remove all items from D.\n",
15491551
" | \n",
1550-
" | pop(self, key, default=<object object at 0x105285160>)\n",
1552+
" | pop(self, key, default=<object object at 0x1008b5160>)\n",
15511553
" | D.pop(k[,d]) -> v, remove specified key and return the corresponding value.\n",
15521554
" | If key is not found, d is returned if given, otherwise KeyError is raised.\n",
15531555
" | \n",

notebooks/exp-config-cb.ipynb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
"outputs": [],
2222
"source": [
2323
"from datetime import datetime, timedelta\n",
24+
"import os\n",
2425
"from freezegun import freeze_time\n",
2526
"from uwtools.api.config import get_yaml_config\n",
2627
"from uwtools.api import chgres_cube\n",
2728
"from uwtools.api.logging import use_uwtools_logger\n",
2829
"\n",
29-
"freeze_time(\"2000-01-01 00:00:00 UTC\").start()\n",
30+
"if os.environ.get(\"FAKE_NOW\"):\n",
31+
" freeze_time(\"2000-01-01 00:00:00 UTC\").start()\n",
3032
"use_uwtools_logger()"
3133
]
3234
},
@@ -362,7 +364,7 @@
362364
{
363365
"data": {
364366
"text/plain": [
365-
"20000101 06:00:00 chgres_cube valid schema <4375563952>"
367+
"20000101 06:00:00 chgres_cube valid schema <4375272848>"
366368
]
367369
},
368370
"execution_count": 8,

notebooks/fs.ipynb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,16 @@
3636
"metadata": {},
3737
"outputs": [],
3838
"source": [
39+
"import os\n",
3940
"from pathlib import Path\n",
4041
"from shutil import rmtree\n",
4142
"from freezegun import freeze_time\n",
4243
"from uwtools.api import fs\n",
4344
"from uwtools.api.logging import use_uwtools_logger\n",
4445
"import yaml\n",
4546
"\n",
46-
"freeze_time(\"2000-01-01 00:00:00 UTC\").start()\n",
47+
"if os.environ.get(\"FAKE_NOW\"):\n",
48+
" freeze_time(\"2000-01-01 00:00:00 UTC\").start()\n",
4749
"use_uwtools_logger()"
4850
]
4951
},
@@ -498,7 +500,7 @@
498500
{
499501
"data": {
500502
"text/plain": [
501-
"File copies <4431768352>"
503+
"File copies <4444596256>"
502504
]
503505
},
504506
"execution_count": 12,
@@ -1016,7 +1018,7 @@
10161018
{
10171019
"data": {
10181020
"text/plain": [
1019-
"File links <4431571600>"
1021+
"File links <4444596304>"
10201022
]
10211023
},
10221024
"execution_count": 24,
@@ -1418,7 +1420,7 @@
14181420
{
14191421
"data": {
14201422
"text/plain": [
1421-
"Directories <4432233664>"
1423+
"Directories <4444756432>"
14221424
]
14231425
},
14241426
"execution_count": 34,

notebooks/rocoto.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@
2828
"metadata": {},
2929
"outputs": [],
3030
"source": [
31+
"import os\n",
3132
"from pathlib import Path\n",
3233
"from freezegun import freeze_time\n",
3334
"from uwtools.api import rocoto\n",
3435
"from uwtools.api.logging import use_uwtools_logger\n",
3536
"\n",
36-
"freeze_time(\"2000-01-01 00:00:00 UTC\").start()\n",
37+
"if os.environ.get(\"FAKE_NOW\"):\n",
38+
" freeze_time(\"2000-01-01 00:00:00 UTC\").start()\n",
3739
"use_uwtools_logger()"
3840
]
3941
},

notebooks/template.ipynb

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,15 @@
2424
"execution_count": 1,
2525
"id": "cbec4cc0-369e-41ff-a8a6-8a2699cb5759",
2626
"metadata": {},
27-
"outputs": [
28-
{
29-
"data": {
30-
"text/plain": [
31-
"<freezegun.api.FrozenDateTimeFactory at 0x106570790>"
32-
]
33-
},
34-
"execution_count": 1,
35-
"metadata": {},
36-
"output_type": "execute_result"
37-
}
38-
],
27+
"outputs": [],
3928
"source": [
29+
"import os\n",
4030
"from pathlib import Path\n",
4131
"from freezegun import freeze_time\n",
4232
"from uwtools.api import template\n",
4333
"\n",
44-
"freeze_time(\"2000-01-01 00:00:00 UTC\").start()"
34+
"if os.environ.get(\"FAKE_NOW\"):\n",
35+
" freeze_time(\"2000-01-01 00:00:00 UTC\").start()"
4536
]
4637
},
4738
{

0 commit comments

Comments
 (0)