mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
Convert C++ NotImplementedError to Python NotImplementedError
This commit is contained in:
committed by
Ingmar Schoegl
parent
11a0406216
commit
c281601c2c
@@ -225,6 +225,8 @@ inline int translate_exception()
|
||||
PyErr_SetObject(exn.m_type, exn.m_value);
|
||||
} catch (const std::out_of_range& exn) {
|
||||
PyErr_SetString(PyExc_IndexError, exn.what());
|
||||
} catch (const Cantera::NotImplementedError& exn) {
|
||||
PyErr_SetString(PyExc_NotImplementedError, exn.what());
|
||||
} catch (const Cantera::CanteraError& exn) {
|
||||
PyErr_SetString(pyCanteraError, exn.what());
|
||||
} catch (const std::exception& exn) {
|
||||
|
||||
@@ -180,15 +180,15 @@ class TestEmptyThermoPhase(utilities.CanteraTest):
|
||||
cls.gas = ct.ThermoPhase()
|
||||
|
||||
def test_empty_report(self):
|
||||
with self.assertRaisesRegex(ct.CanteraError, "NotImplementedError"):
|
||||
with pytest.raises(NotImplementedError):
|
||||
self.gas()
|
||||
|
||||
def test_empty_TP(self):
|
||||
with self.assertRaisesRegex(ct.CanteraError, "NotImplementedError"):
|
||||
with pytest.raises(NotImplementedError):
|
||||
self.gas.TP = 300, ct.one_atm
|
||||
|
||||
def test_empty_equilibrate(self):
|
||||
with self.assertRaisesRegex(ct.CanteraError, "NotImplementedError"):
|
||||
with pytest.raises(NotImplementedError):
|
||||
self.gas.equilibrate("TP")
|
||||
|
||||
|
||||
|
||||
@@ -800,7 +800,7 @@ class cti2yamlTest(utilities.CanteraTest):
|
||||
cp_cti = ctiPhase.partial_molar_cp
|
||||
cp_yaml = yamlPhase.partial_molar_cp
|
||||
else:
|
||||
with pytest.raises(ct.CanteraError):
|
||||
with pytest.raises(NotImplementedError):
|
||||
yamlPhase.partial_molar_cp
|
||||
h_cti = ctiPhase.partial_molar_enthalpies
|
||||
h_yaml = yamlPhase.partial_molar_enthalpies
|
||||
@@ -1024,7 +1024,7 @@ class ctml2yamlTest(utilities.CanteraTest):
|
||||
cp_ctml = ctmlPhase.partial_molar_cp
|
||||
cp_yaml = yamlPhase.partial_molar_cp
|
||||
else:
|
||||
with pytest.raises(ct.CanteraError):
|
||||
with pytest.raises(NotImplementedError):
|
||||
yamlPhase.partial_molar_cp
|
||||
h_ctml = ctmlPhase.partial_molar_enthalpies
|
||||
h_yaml = yamlPhase.partial_molar_enthalpies
|
||||
|
||||
@@ -676,7 +676,7 @@ class TestFreeFlame(utilities.CanteraTest):
|
||||
|
||||
try:
|
||||
soln_value = getattr(self.gas, attr)
|
||||
except (ct.CanteraError, ct.ThermoModelMethodError):
|
||||
except (ct.CanteraError, ct.ThermoModelMethodError, NotImplementedError):
|
||||
continue
|
||||
|
||||
if not isinstance(soln_value, (float, np.ndarray)):
|
||||
|
||||
@@ -540,7 +540,7 @@ class TestReactor(utilities.CanteraTest):
|
||||
with self.assertRaisesRegex(Exception, 'eggs'):
|
||||
self.net.step()
|
||||
|
||||
with self.assertRaisesRegex(ct.CanteraError, 'NotImplementedError'):
|
||||
with pytest.raises(NotImplementedError):
|
||||
mfc.set_pressure_function(lambda p: p**2)
|
||||
|
||||
def test_valve1(self):
|
||||
@@ -738,7 +738,7 @@ class TestReactor(utilities.CanteraTest):
|
||||
p = ct.PressureController(self.r1, self.r2)
|
||||
p.mass_flow_rate
|
||||
|
||||
with self.assertRaisesRegex(ct.CanteraError, 'NotImplementedError'):
|
||||
with pytest.raises(NotImplementedError):
|
||||
p = ct.PressureController(self.r1, self.r2)
|
||||
p.set_time_function(lambda t: t>1.)
|
||||
|
||||
|
||||
@@ -1938,7 +1938,7 @@ class TestSolutionArray(utilities.CanteraTest):
|
||||
|
||||
try:
|
||||
soln_value = getattr(self.gas, attr)
|
||||
except (ct.CanteraError, ct.ThermoModelMethodError):
|
||||
except (ct.CanteraError, ct.ThermoModelMethodError, NotImplementedError):
|
||||
continue
|
||||
|
||||
if not isinstance(soln_value, (float, np.ndarray)):
|
||||
|
||||
@@ -90,7 +90,7 @@ class TestTransport(utilities.CanteraTest):
|
||||
self.assertArrayNear(Dbin1, Dbin2)
|
||||
|
||||
def test_multiComponent(self):
|
||||
with self.assertRaisesRegex(ct.CanteraError, 'NotImplementedError'):
|
||||
with pytest.raises(NotImplementedError):
|
||||
self.phase.multi_diff_coeffs
|
||||
|
||||
self.assertArrayNear(self.phase.thermal_diff_coeffs,
|
||||
|
||||
Reference in New Issue
Block a user