Skip to content

Commit e49037c

Browse files
committed
refactoring the test, using pytest
1 parent 02fb7dd commit e49037c

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

tests/test_transformer.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from pvlib import transformer
66

7+
import pytest
78

89
def test_simple_efficiency():
910

@@ -59,12 +60,18 @@ def test_simple_efficiency_known_values():
5960
rating,
6061
)
6162

63+
@pytest.mark.parametrize(
64+
"input_power, no_load_loss, load_loss, transformer_rating, expected",
65+
[
66+
(1000.0, 0.01, 0.0, 1000.0, 990.0),
67+
],
68+
)
6269

63-
def test_simple_efficiency_zero_load_loss():
64-
input_power = 1000.0
65-
no_load_loss = 0.01
66-
load_loss = 0.0
67-
transformer_rating = 1000.0
70+
def test_simple_efficiency_zero_load_loss(
71+
input_power, no_load_loss, load_loss, transformer_rating, expected
72+
):
73+
# for load_loss = 0, the model reduces to:
74+
# P_out = P_in - L_no_load * P_nom
6875

6976
result = transformer.simple_efficiency(
7077
input_power=input_power,
@@ -73,8 +80,4 @@ def test_simple_efficiency_zero_load_loss():
7380
transformer_rating=transformer_rating,
7481
)
7582

76-
# for load_loss = 0, the model reduces to:
77-
# P_out = P_in - L_no_load * P_nom
78-
expected = input_power - no_load_loss * transformer_rating
79-
8083
assert_allclose(result, expected)

0 commit comments

Comments
 (0)