Skip to content

Commit

Permalink
fix[tests]: clear log capture at start of local mode solver test
Browse files Browse the repository at this point in the history
  • Loading branch information
yaugenst-flex committed Jan 15, 2025
1 parent 405aef2 commit 3573f46
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions tests/test_plugins/test_mode_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from tidy3d.plugins.mode.solver import compute_modes
from tidy3d.web.core.environment import Env

from ..utils import assert_log_level, cartesian_to_unstructured
from ..utils import AssertLogLevel, cartesian_to_unstructured

WG_MEDIUM = td.Medium(permittivity=4.0, conductivity=1e-4)
WAVEGUIDE = td.Structure(geometry=td.Box(size=(1.5, 100, 1)), medium=WG_MEDIUM)
Expand Down Expand Up @@ -304,10 +304,12 @@ def test_mode_solver_group_index_warning(group_index_step, log_level, log_captur
grid_spec=td.GridSpec(wavelength=1.0),
run_time=1e-12,
)
mode_spec = td.ModeSpec(
num_modes=1,
group_index_step=group_index_step,
)

with AssertLogLevel(log_capture, log_level):
mode_spec = td.ModeSpec(
num_modes=1,
group_index_step=group_index_step,
)

_ = ModeSolver(
simulation=simulation,
Expand All @@ -316,7 +318,6 @@ def test_mode_solver_group_index_warning(group_index_step, log_level, log_captur
freqs=[1e12],
direction="+",
)
assert_log_level(log_capture, log_level)


def test_mode_solver_fields():
Expand Down Expand Up @@ -833,17 +834,10 @@ def test_group_index(mock_remote_api, log_capture, local):
)
modes = ms.solve() if local else msweb.run(ms)
if local:
assert modes.n_group is None
assert len(log_capture) == 1
assert modes.dispersion is None
assert len(log_capture) == 2
for log_msg in log_capture:
assert log_msg[0] == 30
assert "ModeSpec" in log_msg[1]
_ = modes.n_group
assert len(log_capture) == 2
_ = modes.dispersion
assert len(log_capture) == 2
with AssertLogLevel(log_capture, "WARNING", contains_str="ModeSpec"):
assert modes.n_group is None
with AssertLogLevel(log_capture, "WARNING", contains_str="ModeSpec"):
assert modes.dispersion is None
check_ms_reduction(ms)

# Group index calculated
Expand Down

0 comments on commit 3573f46

Please sign in to comment.