Skip to content

Commit ec9ebeb

Browse files
committed
catch warnings instead of filter warnings
Signed-off-by: Martijn Govers <[email protected]>
1 parent 4c23843 commit ec9ebeb

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

tests/validation/converters/test_pandapower_converter_input.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
# SPDX-License-Identifier: MPL-2.0
44

55
import json
6+
import warnings
67
from functools import lru_cache
78
from pathlib import Path
89
from typing import List, Tuple
910

11+
import numpy as np
1012
import pandas as pd
1113
import pytest
1214
from power_grid_model import ComponentType, DatasetType
@@ -118,14 +120,17 @@ def test_extra_info__serializable(extra_info):
118120
json.dumps(actual, cls=JsonEncoder) # expect no exception
119121

120122

121-
@pytest.mark.filterwarnings("error:.*invalid value encountered in divide.*:RuntimeWarning")
122123
def test_pgm_input_lines__cnf_zero():
123-
pp_network = pp_net_3ph_minimal_trafo()
124-
pp_converter = PandaPowerConverter()
125-
pp_network.line.c_nf_per_km = 0
126-
data, _ = pp_converter.load_input_data(pp_network)
127-
assert data[ComponentType.line]["tan1"] == 0
128-
pp_network.line.c_nf_per_km = 0.001
129-
pp_network.line.c0_nf_per_km = 0
130-
data, _ = pp_converter.load_input_data(pp_network)
131-
assert data[ComponentType.line]["tan0"] == 0
124+
with warnings.catch_warnings():
125+
warnings.simplefilter("error")
126+
127+
pp_network = pp_net_3ph_minimal_trafo()
128+
pp_converter = PandaPowerConverter()
129+
pp_network.line.c_nf_per_km = 0
130+
data, _ = pp_converter.load_input_data(pp_network)
131+
np.testing.assert_array_equal(data[ComponentType.line]["tan1"], 0)
132+
133+
pp_network.line.c_nf_per_km = 0.001
134+
pp_network.line.c0_nf_per_km = 0
135+
data, _ = pp_converter.load_input_data(pp_network)
136+
np.testing.assert_array_equal(data[ComponentType.line]["tan0"], 0)

0 commit comments

Comments
 (0)