44from unittest .mock import MagicMock , patch
55
66import numpy as np
7+ import pytest
78from power_grid_model import WindingType
8- from pytest import approx , mark
99
1010from power_grid_model_io .functions import (
1111 both_zeros_to_nan ,
2020)
2121
2222
23- @mark .parametrize (
23+ @pytest . mark .parametrize (
2424 ("value" , "expected" ),
2525 [
2626 (None , False ),
3737 ],
3838)
3939def test_has_value (value , expected ):
40- assert has_value (value ) == approx (expected )
40+ assert has_value (value ) == pytest . approx (expected )
4141
4242
4343@patch ("power_grid_model_io.functions.has_value" )
@@ -58,7 +58,7 @@ def test_value_or_zero(mock_value_or_default: MagicMock):
5858 mock_value_or_default .assert_called_once_with (value = 1.23 , default = 0.0 )
5959
6060
61- @mark .parametrize (
61+ @pytest . mark .parametrize (
6262 ("real" , "imag" , "expected" ),
6363 [
6464 (float ("nan" ), float ("nan" ), float ("nan" )),
@@ -70,10 +70,10 @@ def test_value_or_zero(mock_value_or_default: MagicMock):
7070)
7171def test_complex_inverse_real_part (real : float , imag : float , expected : float ):
7272 actual = complex_inverse_real_part (real , imag )
73- assert actual == approx (expected ) or (np .isnan (actual ) and np .isnan (expected ))
73+ assert actual == pytest . approx (expected ) or (np .isnan (actual ) and np .isnan (expected ))
7474
7575
76- @mark .parametrize (
76+ @pytest . mark .parametrize (
7777 ("real" , "imag" , "expected" ),
7878 [
7979 (float ("nan" ), float ("nan" ), float ("nan" )),
@@ -85,10 +85,10 @@ def test_complex_inverse_real_part(real: float, imag: float, expected: float):
8585)
8686def test_complex_inverse_imaginary_part (real : float , imag : float , expected : float ):
8787 actual = complex_inverse_imaginary_part (real , imag )
88- assert actual == approx (expected ) or (np .isnan (actual ) and np .isnan (expected ))
88+ assert actual == pytest . approx (expected ) or (np .isnan (actual ) and np .isnan (expected ))
8989
9090
91- @mark .parametrize (
91+ @pytest . mark .parametrize (
9292 ("winding" , "neutral_grounding" , "expected" ),
9393 [
9494 ("Y" , True , WindingType .wye ),
@@ -118,7 +118,7 @@ def test_get_winding(winding: str, neutral_grounding: bool, expected: WindingTyp
118118 assert actual == expected
119119
120120
121- @mark .parametrize (
121+ @pytest . mark .parametrize (
122122 ("degrees" , "expected" ),
123123 [
124124 (360 , 0 ),
@@ -129,10 +129,10 @@ def test_get_winding(winding: str, neutral_grounding: bool, expected: WindingTyp
129129)
130130def test_degrees_to_clock (degrees : float , expected : int ):
131131 actual = degrees_to_clock (degrees )
132- assert actual == approx (expected ) or (np .isnan (actual ) and np .isnan (expected ))
132+ assert actual == pytest . approx (expected ) or (np .isnan (actual ) and np .isnan (expected ))
133133
134134
135- @mark .parametrize (
135+ @pytest . mark .parametrize (
136136 ("left_side" , "right_side" , "expected" ),
137137 [
138138 (float ("nan" ), float ("nan" ), False ),
@@ -146,7 +146,7 @@ def test_is_greater_than(left_side: float, right_side: list[float], expected: fl
146146 assert actual == expected
147147
148148
149- @mark .parametrize (
149+ @pytest . mark .parametrize (
150150 ("value" , "other_value" , "expected" ),
151151 [
152152 (float ("nan" ), float ("nan" ), float ("nan" )),
@@ -162,4 +162,4 @@ def test_is_greater_than(left_side: float, right_side: list[float], expected: fl
162162)
163163def test_both_zeros_to_nan (value : float , other_value : float , expected : float ):
164164 actual = both_zeros_to_nan (value , other_value )
165- assert actual == approx (expected ) or (np .isnan (actual ) and np .isnan (expected ))
165+ assert actual == pytest . approx (expected ) or (np .isnan (actual ) and np .isnan (expected ))
0 commit comments