Skip to content

Commit

Permalink
Remove constructors of testclasses for pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
daklauss committed Jan 7, 2025
1 parent 7b0c857 commit 7b819d6
Show file tree
Hide file tree
Showing 24 changed files with 3 additions and 163 deletions.
3 changes: 0 additions & 3 deletions tests/test_binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

class Test_Binding(unittest.TestCase):

def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):

component_system = ComponentSystem(2)
Expand Down
3 changes: 0 additions & 3 deletions tests/test_buffer_capacity.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

class TestBufferCapacity(unittest.TestCase):

def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
self.components_simple = ComponentSystem(2, charges=[1, 2])

Expand Down
2 changes: 0 additions & 2 deletions tests/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@


class TestCache(unittest.TestCase):
def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
self.cache_dict = ResultsCache(use_diskcache=False)
Expand Down
3 changes: 0 additions & 3 deletions tests/test_cadet_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ def detect_cadet(install_path: Optional[Path] = None):

class Test_Adapter(unittest.TestCase):

def __init__(self, methodName='runTest'):
super().__init__(methodName)

@unittest.skipIf(found_cadet is False, "Skip if CADET is not installed.")
def test_check_cadet(self):
simulator = Cadet(install_path)
Expand Down
3 changes: 0 additions & 3 deletions tests/test_carousel.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@

class Test_Carousel(unittest.TestCase):

def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
self.component_system = ComponentSystem(2)

Expand Down
3 changes: 0 additions & 3 deletions tests/test_compartment.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

class Test_CompartmentBuilder(unittest.TestCase):

def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
self.component_system = ComponentSystem(2)

Expand Down
12 changes: 0 additions & 12 deletions tests/test_difference.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@

from CADETProcess.comparison import SSE
class TestSSE(unittest.TestCase):
def __init__(self, methodName='runTest'):
super().__init__(methodName)

def test_metric(self):
# Compare with itself
Expand Down Expand Up @@ -76,8 +74,6 @@ def test_metric(self):

from CADETProcess.comparison import NRMSE
class TestNRMSE(unittest.TestCase):
def __init__(self, methodName='runTest'):
super().__init__(methodName)

def test_metric(self):
# Compare with itself
Expand Down Expand Up @@ -112,8 +108,6 @@ def test_metric(self):

from CADETProcess.comparison import PeakHeight
class TestPeakHeight(unittest.TestCase):
def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
# 2 Components, gaussian peaks, constant flow
Expand Down Expand Up @@ -202,8 +196,6 @@ def test_metric(self):

from CADETProcess.comparison import PeakPosition
class TestPeakPosition(unittest.TestCase):
def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
# 2 Components, gaussian peaks, constant flow
Expand Down Expand Up @@ -275,8 +267,6 @@ def test_metric(self):

from CADETProcess.comparison import Shape
class TestShape(unittest.TestCase):
def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
# 2 Components, gaussian peaks, constant flow
Expand Down Expand Up @@ -396,8 +386,6 @@ def test_metric(self):


class TestFractionation(unittest.TestCase):
def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
fraction_1 = Fraction(
Expand Down
4 changes: 0 additions & 4 deletions tests/test_equilibrium.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@


class TestReactionEquilibrium(unittest.TestCase):
def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
component_system = ComponentSystem(2)
Expand Down Expand Up @@ -171,8 +169,6 @@ def test_reaction_equilibrium(self):


class TestAdsorptionEquilibrium(unittest.TestCase):
def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
component_system_mono = ComponentSystem()
Expand Down
6 changes: 3 additions & 3 deletions tests/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@


class TestPerformer(Structure):
__test__ = False
n_entries = 4
n_coeff = 4

Expand Down Expand Up @@ -80,6 +81,8 @@ def section_dependent_parameters(self):


class TestHandler(CADETProcess.dynamicEvents.EventHandler):
__test__ = False

def __init__(self):
self.name = None
self.performer = TestPerformer()
Expand Down Expand Up @@ -117,9 +120,6 @@ def polynomial_parameters(self):

class Test_Events(unittest.TestCase):

def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setup_event_handler(self, add_events=False):
event_handler = TestHandler()
event_handler.cycle_time = 20
Expand Down
16 changes: 0 additions & 16 deletions tests/test_flow_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ def setup_ssr_flow_sheet(component_system=None):
class TestFlowSheet(unittest.TestCase):
"""Test general functionatlity of `FlowSheet` class."""

def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
self.component_system = ComponentSystem(2)

Expand Down Expand Up @@ -995,9 +992,6 @@ class TestCstrFlowRate(unittest.TestCase):
is set, it has properties similar to an `Inlet`.
"""

def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
self.component_system = ComponentSystem(2)

Expand Down Expand Up @@ -1100,8 +1094,6 @@ def test_state_update(self):
np.testing.assert_almost_equal(cstr_out, cstr_out_expected)

class TestPorts(unittest.TestCase):
def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
self.setup_mct_flow_sheet()
Expand Down Expand Up @@ -1561,9 +1553,6 @@ def test_set_output_state(self):
class TestFlowRateMatrix(unittest.TestCase):
"""Test calculation of flow rates with another simple testcase by @daklauss"""

def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
self.component_system = ComponentSystem(1)

Expand Down Expand Up @@ -1698,8 +1687,6 @@ def test_matrix_example(self):

class TestFlowRateSelfMatrix(unittest.TestCase):
"""Test special case where one unit is connected to itself."""
def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
self.component_system = ComponentSystem(1)
Expand Down Expand Up @@ -1794,9 +1781,6 @@ class TestSingularFlowMatrix(unittest.TestCase):
"""

def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):

self.component_system = ComponentSystem(1)
Expand Down
3 changes: 0 additions & 3 deletions tests/test_fractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

class Test_Fractions(unittest.TestCase):

def __init__(self, methodName='runTest'):
super().__init__(methodName)

def create_fractions(self):
m_0 = np.array([0, 0])
frac0 = CADETProcess.fractionation.Fraction(m_0, 1)
Expand Down
3 changes: 0 additions & 3 deletions tests/test_individual.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ def test_hash_array(self):


class TestIndividual(unittest.TestCase):
def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
x = [1, 2]
f = [-1]
Expand Down
29 changes: 0 additions & 29 deletions tests/test_optimization_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ def min_results_2(cheap_results):


class Test_OptimizationVariable(unittest.TestCase):

def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
self.evaluation_object = EvaluationObject()

Expand Down Expand Up @@ -332,10 +328,6 @@ def test_transform(self):

from tests.test_events import TestHandler
class Test_OptimizationVariableEvents(unittest.TestCase):

def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
evaluation_object = TestHandler()

Expand Down Expand Up @@ -669,9 +661,6 @@ def setup_optimization_problem(


class Test_OptimizationProblemSimple(unittest.TestCase):
def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
optimization_problem = OptimizationProblem('simple', use_diskcache=False)

Expand Down Expand Up @@ -708,9 +697,6 @@ def test_bounds(self):


class Test_OptimizationProblemLinCon(unittest.TestCase):
def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
optimization_problem = setup_optimization_problem(
n_lincon=1, use_diskcache=False
Expand Down Expand Up @@ -832,9 +818,6 @@ def test_initial_values(self):


class Test_OptimizationProblemDepVar(unittest.TestCase):
def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
optimization_problem = OptimizationProblem('simple', use_diskcache=False)

Expand Down Expand Up @@ -1007,9 +990,6 @@ def test_initial_values(self):


class Test_OptimizationProblemJacobian(unittest.TestCase):
def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
def single_obj_single_var(x):
return x[0]**2
Expand Down Expand Up @@ -1095,9 +1075,6 @@ class Test_OptimizationProblemConstraintTransforms(unittest.TestCase):
tests if `A_transformed` and `b_transformed` properties are correctly
computed.
"""
def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setup(self):
settings.working_directory = './test_problem'

Expand Down Expand Up @@ -1229,9 +1206,6 @@ class Test_OptimizationProblemEvaluator(unittest.TestCase):
"""

def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
eval_obj = EvaluationObject()

Expand Down Expand Up @@ -1309,9 +1283,6 @@ def test_cache(self):


class Test_MultiEvaluationObjects(unittest.TestCase):
def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
eval_obj_1 = EvaluationObject(name='foo')
eval_obj_2 = EvaluationObject(name='bar')
Expand Down
3 changes: 0 additions & 3 deletions tests/test_optimization_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ def setup_optimization_results(


class TestOptimizationResults(unittest.TestCase):
def __init__(self, methodName='runTest'):
super().__init__(methodName)

def setUp(self):
self.optimization_results = setup_optimization_results()

Expand Down
9 changes: 0 additions & 9 deletions tests/test_parallelization_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
class TestParallelizationBackend(unittest.TestCase):
"""Test initializing parallelization backends and n_cores attribute."""

def __init__(self, methodName='runTest'):
super().__init__(methodName)

def test_n_cores(self):
with self.assertRaises(ValueError):
sequential_backend = SequentialBackend(n_cores=n_cores)
Expand Down Expand Up @@ -89,9 +86,6 @@ class TestParallelEvaluation(unittest.TestCase):
"""

def __init__(self, methodName='runTest'):
super().__init__(methodName)

def tearDown(self):
shutil.rmtree('./tmp', ignore_errors=True)
shutil.rmtree('./test_parallelization', ignore_errors=True)
Expand Down Expand Up @@ -140,9 +134,6 @@ class TestOptimizerParallelizationBackend(unittest.TestCase):
"""

def __init__(self, methodName='runTest'):
super().__init__(methodName)

def tearDown(self):
settings.working_directory = None

Expand Down
Loading

0 comments on commit 7b819d6

Please sign in to comment.