Skip to content

Commit 342b808

Browse files
committed
Fix test_variable_func.py
1 parent 8dafb4a commit 342b808

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/pownet/optim_model/variable_func.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""variable.py: Contains functions for adding variables to the optimization model."""
1+
"""variable_func.py: Contains functions for adding variables to the optimization model."""
22

33
import gurobipy as gp
44
from gurobipy import GRB

src/test_pownet/test_optim_model/test_variable_func.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""test_variable_func.py"""
2+
13
import unittest
24
from unittest.mock import MagicMock, patch, call
35
import pandas as pd
@@ -7,8 +9,16 @@
79

810
class TestVariableFunctions(unittest.TestCase):
911

12+
@classmethod
13+
def setUpClass(cls):
14+
"""Set up class-level resources or patches before any tests in the class run."""
15+
variable_func.VAR_PREFIX_THERMAL_GENERATION = "thermal_generation"
16+
1017
def setUp(self):
1118
"""Set up common test data and mocks."""
19+
20+
self.VAR_PREFIX_THERMAL_GENERATION = "thermal_generation"
21+
1222
self.timesteps = range(
1323
3
1424
) # Global timestep as per user request (implicitly via usage)
@@ -251,9 +261,4 @@ def edge_hour_side_effect(var_name):
251261

252262
# This allows running the tests directly from the script
253263
if __name__ == "__main__":
254-
255-
# Ensure the variable prefix is set for the test
256-
if not hasattr(variable_func, "VAR_PREFIX_THERMAL_GENERATION"):
257-
variable_func.VAR_PREFIX_THERMAL_GENERATION = "thermal_generation"
258-
259264
unittest.main()

0 commit comments

Comments
 (0)