Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing testcase.py file #4231

Merged
merged 4 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@
get_optional_distribution_deps,
get_present_optional_import_deps,
no_internet_connection,
assert_domain_equal,
)
from .testcase import TestCase
4 changes: 2 additions & 2 deletions tests/integration/test_experiments.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#
# Test some experiments
#
from tests import TestCase

import pybamm
import numpy as np
import unittest


class TestExperiments(TestCase):
class TestExperiments(unittest.TestCase):
def test_discharge_rest_charge(self):
experiment = pybamm.Experiment(
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#
# Tests for the surface formulation
#
from tests import TestCase

import pybamm
import numpy as np
import unittest
from tests import StandardOutputComparison


class TestCompareOutputs(TestCase):
class TestCompareOutputs(unittest.TestCase):
def test_compare_outputs_surface_form(self):
# load models
options = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
import pybamm
import numpy as np
import unittest
from tests import TestCase


class TestCompareOutputsTwoPhase(TestCase):
class TestCompareOutputsTwoPhase(unittest.TestCase):
def compare_outputs_two_phase_graphite_graphite(self, model_class):
"""
Check that a two-phase graphite-graphite model gives the same results as a
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#
# Tests for the lithium-ion DFN model
#
from tests import TestCase

import pybamm
import tests
import numpy as np
import unittest
from tests import BaseIntegrationTestLithiumIon


class TestDFN(BaseIntegrationTestLithiumIon, TestCase):
class TestDFN(BaseIntegrationTestLithiumIon, unittest.TestCase):
def setUp(self):
self.model = pybamm.lithium_ion.DFN

Expand All @@ -35,7 +35,7 @@ def positive_radius(x):
self.run_basic_processing_test({}, parameter_values=param)


class TestDFNWithSizeDistribution(TestCase):
class TestDFNWithSizeDistribution(unittest.TestCase):
def setUp(self):
params = pybamm.ParameterValues("Marquis2019")
self.params = pybamm.get_size_distribution_parameters(params)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#
# Tests for the lithium-ion MPM model
#
from tests import TestCase

import pybamm
import tests
import numpy as np
import unittest


class TestMPM(TestCase):
class TestMPM(unittest.TestCase):
def test_basic_processing(self):
options = {"thermal": "isothermal"}
model = pybamm.lithium_ion.MPM(options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
import pybamm
import numpy as np
import unittest
from tests import TestCase


class TestThermal(TestCase):
class TestThermal(unittest.TestCase):
def test_consistent_cooling(self):
"Test the cooling is consistent between the 1D, 1+1D and 2+1D SPMe models"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#
# Test function control submodel
#
from tests import TestCase

import numpy as np
import pybamm
import unittest


class TestFunctionControl(TestCase):
class TestFunctionControl(unittest.TestCase):
def test_constant_current(self):
def constant_current(variables):
I = variables["Current [A]"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#
# Tests for the electrode-electrolyte interface equations
#
from tests import TestCase

import pybamm
from tests import get_discretisation_for_testing

import unittest
import numpy as np


class TestButlerVolmer(TestCase):
class TestButlerVolmer(unittest.TestCase):
def setUp(self):
self.delta_phi_s_n = pybamm.Variable(
"surface potential difference [V]",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#
# Tests for the electrode-electrolyte interface equations for lead-acid models
#
from tests import TestCase

import pybamm
from tests import get_discretisation_for_testing
import unittest


class TestMainReaction(TestCase):
class TestMainReaction(unittest.TestCase):
def setUp(self):
c_e_n = pybamm.Variable(
"Negative electrolyte concentration [mol.m-3]",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#
# Tests for the electrode-electrolyte interface equations for lithium-ion models
#
from tests import TestCase

import pybamm
from tests import get_discretisation_for_testing

import unittest
import numpy as np


class TestExchangeCurrentDensity(TestCase):
class TestExchangeCurrentDensity(unittest.TestCase):
def setUp(self):
c_e_n = pybamm.Variable("concentration", domain=["negative electrode"])
c_e_s = pybamm.Variable("concentration", domain=["separator"])
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_solvers/test_idaklu.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import pybamm
import numpy as np
import sys
from tests import TestCase

import unittest


@unittest.skipIf(not pybamm.have_idaklu(), "idaklu solver is not installed")
class TestIDAKLUSolver(TestCase):
class TestIDAKLUSolver(unittest.TestCase):
def test_on_spme(self):
model = pybamm.lithium_ion.SPMe()
geometry = model.default_geometry
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_solvers/test_solution.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#
# Tests for the Solution class
#
from tests import TestCase

import pybamm
import unittest
import numpy as np


class TestSolution(TestCase):
class TestSolution(unittest.TestCase):
def test_append(self):
model = pybamm.lithium_ion.SPMe()
# create geometry
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/test_spatial_methods/test_finite_volume.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Test for the operator class
#
from tests import TestCase

import pybamm
from tests import (
get_mesh_for_testing,
Expand All @@ -13,7 +13,7 @@
import unittest


class TestFiniteVolumeConvergence(TestCase):
class TestFiniteVolumeConvergence(unittest.TestCase):
def test_grad_div_broadcast(self):
# create mesh and discretisation
spatial_methods = {"macroscale": pybamm.FiniteVolume()}
Expand Down Expand Up @@ -319,7 +319,7 @@ def solve_laplace_equation(coord_sys="cartesian"):
return solver.solve(model)


class TestFiniteVolumeLaplacian(TestCase):
class TestFiniteVolumeLaplacian(unittest.TestCase):
def test_laplacian_cartesian(self):
solution = solve_laplace_equation(coord_sys="cartesian")
np.testing.assert_array_almost_equal(
Expand Down Expand Up @@ -374,7 +374,7 @@ def solve_advection_equation(direction="upwind", source=1, bc=0):
return solver.solve(model, [0, 1])


class TestUpwindDownwind(TestCase):
class TestUpwindDownwind(unittest.TestCase):
def test_upwind(self):
solution = solve_advection_equation("upwind")
np.testing.assert_array_almost_equal(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Test for the operator class
#
from tests import TestCase

import pybamm

import numpy as np
Expand Down Expand Up @@ -76,7 +76,7 @@ def get_p2d_mesh_for_testing(xpts=None, rpts=10):
return get_mesh_for_testing(xpts=xpts, rpts=rpts, geometry=geometry)


class TestSpectralVolumeConvergence(TestCase):
class TestSpectralVolumeConvergence(unittest.TestCase):
def test_grad_div_broadcast(self):
# create mesh and discretisation
spatial_methods = {"macroscale": pybamm.SpectralVolume()}
Expand Down
7 changes: 7 additions & 0 deletions tests/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,10 @@ def no_internet_connection():
return False
except socket.gaierror:
return True


def assert_domain_equal(a, b):
"Check that two domains are equal, ignoring empty domains"
a_dict = {k: v for k, v in a.items() if v != []}
b_dict = {k: v for k, v in b.items() if v != []}
assert a_dict == b_dict
3 changes: 1 addition & 2 deletions tests/unit/test_batch_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
Tests for the batch_study.py
"""

from tests import TestCase
import os
import pybamm
import unittest
from tempfile import TemporaryDirectory


class TestBatchStudy(TestCase):
class TestBatchStudy(unittest.TestCase):
def test_solve(self):
spm = pybamm.lithium_ion.SPM()
spm_uniform = pybamm.lithium_ion.SPM({"particle": "uniform profile"})
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_callbacks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Tests the citations class.
#
from tests import TestCase

import pybamm
import unittest
import os
Expand All @@ -18,7 +18,7 @@ def on_experiment_end(self, logs):
print(self.name, file=f)


class TestCallbacks(TestCase):
class TestCallbacks(unittest.TestCase):
def tearDown(self):
# Remove any test log files that were created, even if the test fails
for logfile in ["test_callback.log", "test_callback_2.log"]:
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_discretisations/test_discretisation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Tests for the base model class
#
from tests import TestCase

import pybamm

import numpy as np
Expand All @@ -18,7 +18,7 @@
from scipy.sparse.linalg import inv


class TestDiscretise(TestCase):
class TestDiscretise(unittest.TestCase):
def test_concatenate_in_order(self):
a = pybamm.Variable("a")
b = pybamm.Variable("b")
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_experiments/test_experiment.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#
# Test the base experiment class
#
from tests import TestCase

from datetime import datetime
import pybamm
import unittest


class TestExperiment(TestCase):
class TestExperiment(unittest.TestCase):
def test_cycle_unpacking(self):
experiment = pybamm.Experiment(
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#
# Test setting up a simulation with an experiment
#
from tests import TestCase
import casadi
import pybamm
import numpy as np
Expand All @@ -16,7 +15,7 @@ def default_duration(self, value):
return 1


class TestSimulationExperiment(TestCase):
class TestSimulationExperiment(unittest.TestCase):
def test_set_up(self):
experiment = pybamm.Experiment(
[
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_expression_tree/test_averages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# Tests for the Unary Operator classes
#
import unittest
from tests import TestCase
import numpy as np
import pybamm
from tests import assert_domain_equal


class TestUnaryOperators(TestCase):
class TestUnaryOperators(unittest.TestCase):
def test_x_average(self):
a = pybamm.Scalar(4)
average_a = pybamm.x_average(a)
Expand Down Expand Up @@ -112,7 +112,7 @@ def test_x_average(self):
)
average_conc_broad = pybamm.x_average(conc_broad)
self.assertIsInstance(average_conc_broad, pybamm.FullBroadcast)
self.assertDomainEqual(
assert_domain_equal(
average_conc_broad.domains,
{"primary": ["current collector"], "secondary": ["test"]},
)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_expression_tree/test_binary_operators.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Tests for the Binary Operator classes
#
from tests import TestCase

import unittest
import unittest.mock as mock

Expand All @@ -19,7 +19,7 @@
}


class TestBinaryOperators(TestCase):
class TestBinaryOperators(unittest.TestCase):
def test_binary_operator(self):
a = pybamm.Symbol("a")
b = pybamm.Symbol("b")
Expand Down
Loading
Loading