Skip to content

Commit 562c394

Browse files
authored
tests: minor cleanup in tests (NOAA-GFDL#181)
* tests: minor cleanup in tests - add `__init__.py` files where missing - `List` -> `list` and `Tuple` -> `tuple` - NDSL has no `Namelist` anymore - cleanup unused import and code in `test_init_from_geos.py` * remove stale reference to ndsl.Namelist
1 parent 41d6d85 commit 562c394

File tree

13 files changed

+16
-24
lines changed

13 files changed

+16
-24
lines changed

tests/main/__init__.py

Whitespace-only changes.

tests/main/driver/test_driver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import unittest.mock
22
from datetime import datetime, timedelta
3-
from typing import Literal, Tuple
3+
from typing import Literal
44

55
import pytest
66

@@ -22,7 +22,7 @@ def get_driver_config(
2222
hours: int = 0,
2323
minutes: int = 0,
2424
seconds: int = 0,
25-
layout: Tuple[int, int] = (1, 1),
25+
layout: tuple[int, int] = (1, 1),
2626
frequency: int = 1,
2727
output_initial_state=False,
2828
start_time_type: Literal["timedelta", "datetime"] = "timedelta",

tests/main/driver/test_example_configs.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22
from pathlib import Path
3-
from typing import List
43

54
import pytest
65
import yaml
@@ -9,7 +8,7 @@
98
from tests.paths import EXAMPLE_CONFIGS_DIR, JENKINS_CONFIGS_DIR
109

1110

12-
TESTED_CONFIGS: List[str] = [
11+
TESTED_CONFIGS: list[str] = [
1312
"baroclinic_c12.yaml",
1413
"baroclinic_c12_dp.yaml",
1514
"baroclinic_c12_explicit_physics.yaml",
@@ -20,7 +19,7 @@
2019
"baroclinic_c48_6ranks_serialbox_test.yaml",
2120
"analytic_test.yaml",
2221
]
23-
EXCLUDED_CONFIGS: List[str] = [
22+
EXCLUDED_CONFIGS: list[str] = [
2423
# We don't test serialbox example because it loads namelist
2524
# filepath that are not in git
2625
"baroclinic_c12_from_serialbox.yaml",
@@ -33,13 +32,13 @@
3332
]
3433

3534

36-
TESTED_JENKINS_CONFIGS: List[str] = [
35+
TESTED_JENKINS_CONFIGS: list[str] = [
3736
"baroclinic_c48_6ranks_dycore_only.yaml",
3837
"baroclinic_c192_6ranks.yaml",
3938
"baroclinic_c192_54ranks.yaml",
4039
]
4140

42-
EXCLUDED_JENKINS_CONFIGS: List[str] = [
41+
EXCLUDED_JENKINS_CONFIGS: list[str] = [
4342
# We don't test serialbox example because it loads namelist
4443
# filepath that are not in git
4544
"baroclinic_c48_6ranks_dycore_only_serialbox.yaml",
@@ -61,7 +60,7 @@
6160
],
6261
)
6362
def test_all_configs_tested_or_excluded(
64-
config_dir: Path, tested_configs: List[str], excluded_configs: List[str]
63+
config_dir: Path, tested_configs: list[str], excluded_configs: list[str]
6564
):
6665
"""
6766
If any configs are not tested or excluded, add them to TESTED_CONFIGS or
@@ -84,7 +83,7 @@ def test_all_configs_tested_or_excluded(
8483
pytest.param(JENKINS_CONFIGS_DIR, TESTED_JENKINS_CONFIGS),
8584
],
8685
)
87-
def test_example_config_can_initialize(path: Path, file_list: List[str]):
86+
def test_example_config_can_initialize(path: Path, file_list: list[str]):
8887
for file_name in file_list:
8988
with open(path / file_name, "r") as f:
9089
config = DriverConfig.from_dict(yaml.safe_load(f))

tests/main/fv3core/__init__.py

Whitespace-only changes.

tests/main/fv3core/test_dycore_call.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from dataclasses import fields
33
from datetime import timedelta
44
from pathlib import Path
5-
from typing import Tuple
65

76
import pyfv3.initialization.analytic_init as ai
87
from ndsl import (
@@ -27,7 +26,7 @@
2726
from pyfv3.initialization.analytic_init import AnalyticCase
2827

2928

30-
def setup_dycore() -> Tuple[DynamicalCore, DycoreState, Timer]:
29+
def setup_dycore() -> tuple[DynamicalCore, DycoreState, Timer]:
3130
backend = Backend("st:numpy:cpu:IJK")
3231
config = DynamicalCoreConfig(
3332
layout=(1, 1),

tests/main/fv3core/test_init_from_geos.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import f90nml
22
import numpy as np
3-
import pytest # noqa
43

54
from ndsl.config import Backend
65
from pace import NullComm
@@ -108,11 +107,6 @@ def test_geos_wrapper():
108107
namelist["nx_tile"] + 2 * nhalo + 1,
109108
namelist["nz"],
110109
)
111-
shape_z_interface = (
112-
namelist["nx_tile"] + 2 * nhalo,
113-
namelist["nx_tile"] + 2 * nhalo,
114-
namelist["nz"] + 1,
115-
)
116110
shape2d = (
117111
namelist["nx_tile"] + 2 * nhalo,
118112
namelist["nx_tile"] + 2 * nhalo,

tests/main/physics/__init__.py

Whitespace-only changes.

tests/mpi/__init__.py

Whitespace-only changes.

tests/mpi/ext_grid/__init__.py

Whitespace-only changes.

tests/mpi/restart/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)