[Python/Test] Use assertRaisesRegex to make tests more specific

This commit is contained in:
Ray Speth 2018-09-15 14:35:13 -04:00
parent 0f1da269fc
commit 09ee87068a
7 changed files with 78 additions and 79 deletions

View file

@ -98,19 +98,19 @@ class chemkinConverterTest(utilities.CanteraTest):
self.assertEqual(gas.n_reactions, 0)
def test_missingElement(self):
with self.assertRaises(ck2cti.InputParseError):
with self.assertRaisesRegex(ck2cti.InputParseError, 'Undefined elements'):
convertMech(pjoin(self.test_data_dir, 'h2o2_missingElement.inp'),
outName=pjoin(self.test_work_dir, 'h2o2_missingElement.cti'),
quiet=True)
def test_missingThermo(self):
with self.assertRaises(ck2cti.InputParseError):
with self.assertRaisesRegex(ck2cti.InputParseError, 'No thermo data'):
convertMech(pjoin(self.test_data_dir, 'h2o2_missingThermo.inp'),
outName=pjoin(self.test_work_dir, 'h2o2_missingThermo.cti'),
quiet=True)
def test_duplicate_thermo(self):
with self.assertRaises(ck2cti.InputParseError):
with self.assertRaisesRegex(ck2cti.InputParseError, 'additional thermo'):
convertMech(pjoin(self.test_data_dir, 'duplicate-thermo.inp'),
outName=pjoin(self.test_work_dir, 'duplicate-thermo.cti'),
quiet=True)
@ -124,7 +124,7 @@ class chemkinConverterTest(utilities.CanteraTest):
self.assertEqual(gas.n_reactions, 2)
def test_duplicate_species(self):
with self.assertRaises(ck2cti.InputParseError):
with self.assertRaisesRegex(ck2cti.InputParseError, 'additional declaration'):
convertMech(pjoin(self.test_data_dir, 'duplicate-species.inp'),
outName=pjoin(self.test_work_dir, 'duplicate-species.cti'),
quiet=True)
@ -168,7 +168,7 @@ class chemkinConverterTest(utilities.CanteraTest):
self.assertEqual(list(nu[:,11]), [0, 0, -1, 0, 2, 0, 0, 0, -1])
def test_unterminatedSections(self):
with self.assertRaises(ck2cti.InputParseError):
with self.assertRaisesRegex(ck2cti.InputParseError, 'implicitly ended'):
convertMech(pjoin(self.test_data_dir, 'unterminated-sections.inp'),
outName=pjoin(self.test_work_dir, 'unterminated-sections.cti'),
quiet=True)
@ -182,7 +182,7 @@ class chemkinConverterTest(utilities.CanteraTest):
self.assertEqual(gas.n_reactions, 2)
def test_unterminatedSections2(self):
with self.assertRaises(ck2cti.InputParseError):
with self.assertRaisesRegex(ck2cti.InputParseError, 'implicitly ended'):
convertMech(pjoin(self.test_data_dir, 'unterminated-sections2.inp'),
outName=pjoin(self.test_work_dir, 'unterminated-sections2.cti'),
quiet=True)
@ -266,7 +266,7 @@ class chemkinConverterTest(utilities.CanteraTest):
self.checkKinetics(ref, gas, [300, 800, 1450, 2800], [5e3, 1e5, 2e6])
def test_negative_order(self):
with self.assertRaises(ck2cti.InputParseError):
with self.assertRaisesRegex(ck2cti.InputParseError, 'Negative reaction order'):
convertMech(pjoin(self.test_data_dir, 'negative-order.inp'),
thermoFile=pjoin(self.test_data_dir, 'dummy-thermo.dat'),
outName=pjoin(self.test_work_dir, 'negative-order.cti'), quiet=True)
@ -342,21 +342,21 @@ class chemkinConverterTest(utilities.CanteraTest):
self.assertTrue(d > 0.0)
def test_transport_missing_species(self):
with self.assertRaises(ck2cti.InputParseError):
with self.assertRaisesRegex(ck2cti.InputParseError, 'No transport data'):
convertMech(pjoin(self.test_data_dir, 'h2o2.inp'),
transportFile=pjoin(self.test_data_dir, 'h2o2-missing-species-tran.dat'),
outName=pjoin(self.test_work_dir, 'h2o2_transport_missing_species.cti'),
quiet=True)
def test_transport_extra_column_entries(self):
with self.assertRaises(ck2cti.InputParseError):
with self.assertRaisesRegex(ck2cti.InputParseError, 'Extra parameters'):
convertMech(pjoin(self.test_data_dir, 'h2o2.inp'),
transportFile=pjoin(self.test_data_dir, 'h2o2-extra-column-entries-tran.dat'),
outName=pjoin(self.test_work_dir, 'h2o2_extra-column-entries-tran.cti'),
quiet=True)
def test_transport_duplicate_species(self):
with self.assertRaises(ck2cti.InputParseError):
with self.assertRaisesRegex(ck2cti.InputParseError, 'duplicate transport'):
convertMech(pjoin(self.test_data_dir, 'h2o2.inp'),
transportFile=pjoin(self.test_data_dir, 'h2o2-duplicate-species-tran.dat'),
outName=pjoin(self.test_work_dir, 'h2o2_transport_duplicate_species.cti'),
@ -369,14 +369,14 @@ class chemkinConverterTest(utilities.CanteraTest):
permissive=True)
def test_transport_bad_geometry(self):
with self.assertRaises(ck2cti.InputParseError):
with self.assertRaisesRegex(ck2cti.InputParseError, 'geometry flag'):
convertMech(pjoin(self.test_data_dir, 'h2o2.inp'),
transportFile=pjoin(self.test_data_dir, 'h2o2-bad-geometry-tran.dat'),
outName=pjoin(self.test_work_dir, 'h2o2_transport_bad_geometry.cti'),
quiet=True)
def test_transport_float_geometry(self):
with self.assertRaises(ck2cti.InputParseError):
with self.assertRaisesRegex(ck2cti.InputParseError, 'geometry flag'):
convertMech(pjoin(self.test_data_dir, 'h2o2.inp'),
transportFile=pjoin(self.test_data_dir, 'h2o2-float-geometry-tran.dat'),
outName=pjoin(self.test_work_dir, 'h2o2_transport_float_geometry.cti'),

View file

@ -54,9 +54,9 @@ class TestKinetics(utilities.CanteraTest):
self.assertNear(self.phase.reaction_type(2), 1) # elementary
self.assertNear(self.phase.reaction_type(20), 4) # falloff
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'out of range'):
self.phase.reaction_type(33)
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'out of range'):
self.phase.reaction_type(-2)
def test_reaction_equations(self):
@ -690,9 +690,8 @@ class TestDuplicateReactions(utilities.CanteraTest):
infile = 'duplicate-reactions.cti'
def check(self, name):
with self.assertRaises(ct.CanteraError) as cm:
with self.assertRaisesRegex(ct.CanteraError, 'duplicate reaction'):
ct.Solution(self.infile, name)
self.assertIn('duplicate reaction', str(cm.exception))
def test_forward_multiple(self):
self.check('A')
@ -814,7 +813,7 @@ class TestReaction(utilities.CanteraTest):
self.assertFalse(r.allow_negative_pre_exponential_factor)
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'negative pre-exponential'):
gas = ct.Solution(thermo='IdealGas', kinetics='GasKinetics',
species=species, reactions=[r])
@ -951,17 +950,17 @@ class TestReaction(utilities.CanteraTest):
tbr = self.gas.reaction(0)
R2 = ct.ElementaryReaction(tbr.reactants, tbr.products)
R2.rate = tbr.rate
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'types are different'):
self.gas.modify_reaction(0, R2)
# different reactants
R = self.gas.reaction(7)
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'Reactants are different'):
self.gas.modify_reaction(23, R)
# different products
R = self.gas.reaction(14)
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'Products are different'):
self.gas.modify_reaction(15, R)
def test_modify_elementary(self):

View file

@ -25,13 +25,13 @@ class TestMixture(utilities.CanteraTest):
m_H = self.mix.element_index('H')
self.assertEqual(m_H, self.mix.element_index(m_H))
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'No such element'):
self.mix.element_index('W')
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'No such element'):
self.mix.element_index(41)
with self.assertRaises(TypeError):
with self.assertRaisesRegex(TypeError, 'must be a string or a number'):
self.mix.element_index(None)
def test_speciesIndex(self):
@ -48,16 +48,16 @@ class TestMixture(utilities.CanteraTest):
self.assertEqual(self.mix.species_index(1, self.phase2.species_index('N2')), kN2)
self.assertEqual(self.mix.species_index(1, 'N2'), kN2)
with self.assertRaises(IndexError):
with self.assertRaisesRegex(IndexError, 'out of range'):
self.mix.species_index(3, 'OH')
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'No such species'):
self.mix.species_index(1, 'OH')
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'out of range'):
self.mix.species_index(0, -2)
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'No such species'):
self.mix.species_index(1, 'CO2')
def test_n_atoms(self):
@ -190,5 +190,5 @@ class TestMixture(utilities.CanteraTest):
def test_invalid_phase_type(self):
water = ct.Water()
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'not compatible'):
self.mix = ct.Mixture([(self.phase1, 1.0), (water, 2.0)])

View file

@ -55,10 +55,10 @@ class TestOnedim(utilities.CanteraTest):
gas = ct.Solution('h2o2.xml')
flame = ct.IdealGasFlow(gas)
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'monotonically'):
flame.grid = [0, 0.1, 0.1, 0.2]
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'monotonically'):
flame.grid = [0, 0.1, 0.2, 0.05]
def test_unpicklable(self):
@ -95,7 +95,7 @@ class TestOnedim(utilities.CanteraTest):
# Some things don't work until the domains have been added to a Sim1D
sim = ct.Sim1D((left, flame, right))
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'no component'):
flame.set_steady_tolerances(foobar=(3e-4, 3e-6))
flame.set_steady_tolerances(default=(5e-3, 5e-5),
@ -325,7 +325,7 @@ class TestFreeFlame(utilities.CanteraTest):
self.assertFalse(self.sim.soret_enabled)
self.assertFalse(self.sim.transport_model == 'Multi')
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'requires.*multicomponent'):
self.sim.soret_enabled = True
self.sim.solve(loglevel=0, auto=False)
@ -507,7 +507,7 @@ class TestFreeFlame(utilities.CanteraTest):
self.sim.set_refine_criteria(*good)
for i in range(4):
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'Refiner::setCriteria'):
vals = list(good)
vals[i] = bad[i]
self.sim.set_refine_criteria(*vals)
@ -539,7 +539,7 @@ class TestFreeFlame(utilities.CanteraTest):
# Set the maximum grid points to be a low number that should
# be exceeded by the refinement
self.sim.max_grid_points = 10
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'max number of grid points'):
self.sim.solve(loglevel=0, refine_grid=True)
def test_set_max_grid_points(self):

View file

@ -46,9 +46,9 @@ class TestReactor(utilities.CanteraTest):
def test_insert(self):
R = self.reactorClass()
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'No phase'):
R.T
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'No phase'):
R.kinetics.net_production_rates
g = ct.Solution('h2o2.xml')
@ -469,12 +469,12 @@ class TestReactor(utilities.CanteraTest):
self.make_reactors()
res = ct.Reservoir()
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'contents not defined'):
# Must assign contents of both reactors before creating Valve
v = ct.Valve(self.r1, res)
v = ct.Valve(self.r1, self.r2)
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'Already installed'):
# inlet and outlet cannot be reassigned
v._install(self.r2, self.r1)
@ -508,15 +508,15 @@ class TestReactor(utilities.CanteraTest):
p = ct.PressureController(self.r1, self.r2, master=mfc, K=0.5)
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'Device is not ready'):
p = ct.PressureController(self.r1, self.r2, K=0.5)
p.mdot(0.0)
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'Device is not ready'):
p = ct.PressureController(self.r1, self.r2, master=mfc)
p.mdot(0.0)
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'Device is not ready'):
p = ct.PressureController(self.r1, self.r2)
p.mdot(0.0)

View file

@ -38,9 +38,9 @@ class TestThermoPhase(utilities.CanteraTest):
kSpec = self.phase.species_index(species)
self.assertEqual(self.phase.n_atoms(kSpec, mElem), n)
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'No such species'):
self.phase.n_atoms('C', 'H2')
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'No such element'):
self.phase.n_atoms('H', 'CH4')
def test_elemental_mass_fraction(self):
@ -55,9 +55,9 @@ class TestThermoPhase(utilities.CanteraTest):
self.assertNear(Zh, 0.5 * (2.01588 / 18.01528))
self.assertEqual(Zar, 0.0)
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'No such element'):
self.phase.elemental_mass_fraction('C')
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'No such element'):
self.phase.elemental_mass_fraction(5)
def test_elemental_mole_fraction(self):
@ -72,9 +72,9 @@ class TestThermoPhase(utilities.CanteraTest):
self.assertNear(Zh, (2*0.5) / (0.5*3 + 0.5*2))
self.assertEqual(Zar, 0.0)
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'No such element'):
self.phase.elemental_mole_fraction('C')
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'No such element'):
self.phase.elemental_mole_fraction(5)
def test_elemental_mass_mole_fraction(self):
@ -127,24 +127,24 @@ class TestThermoPhase(utilities.CanteraTest):
self.assertNear(X[0], 0.5)
self.assertNear(X[3], 0.5)
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'Unknown species'):
self.phase.X = 'H2:1.0, CO2:1.5'
def test_setCompositionStringBad(self):
X0 = self.phase.X
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'Trouble processing'):
self.phase.X = 'H2:1.0, O2:asdf'
self.assertArrayNear(X0, self.phase.X)
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'Trouble processing'):
self.phase.X = 'H2:1e-x4'
self.assertArrayNear(X0, self.phase.X)
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'decimal point in exponent'):
self.phase.X = 'H2:1e-1.4'
self.assertArrayNear(X0, self.phase.X)
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'Duplicate key'):
self.phase.X = 'H2:0.5, O2:1.0, H2:0.1'
self.assertArrayNear(X0, self.phase.X)
@ -186,14 +186,14 @@ class TestThermoPhase(utilities.CanteraTest):
def test_setCompositionNoNormBad(self):
X = np.zeros(self.phase.n_species - 1)
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'incorrect length'):
self.phase.set_unnormalized_mole_fractions(X)
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'incorrect length'):
self.phase.set_unnormalized_mass_fractions([1,2,3])
def test_setCompositionDict_bad1(self):
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'Unknown species'):
self.phase.X = {'H2':1.0, 'HCl':3.0}
def test_setCompositionDict_bad2(self):
@ -214,13 +214,13 @@ class TestThermoPhase(utilities.CanteraTest):
def test_setCompositionSlice_bad(self):
X0 = self.phase.X
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'incorrect length'):
self.phase['H2','O2'].Y = [0.1, 0.2, 0.3]
self.assertArrayNear(self.phase.X, X0)
def test_setCompositionEmpty_bad(self):
X0 = self.phase.X
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'incorrect length'):
self.phase.Y = np.array([])
self.assertArrayNear(self.phase.X, X0)
@ -279,7 +279,7 @@ class TestThermoPhase(utilities.CanteraTest):
self.assertNear(1.0, gas.get_equivalence_ratio(ignore=['NO']))
self.assertNear(0.975, gas.get_equivalence_ratio(oxidizers=['O2']))
self.assertNear(gas.get_equivalence_ratio(), gas.get_equivalence_ratio(oxidizers=['O2', 'NO']))
def test_full_report(self):
report = self.phase.report(threshold=0.0)
self.assertIn(self.phase.name, report)
@ -313,9 +313,9 @@ class TestThermoPhase(utilities.CanteraTest):
def test_badLength(self):
X = np.zeros(5)
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'incorrect length'):
self.phase.X = X
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'incorrect length'):
self.phase.Y = X
def test_mass_basis(self):
@ -449,13 +449,13 @@ class TestThermoPhase(utilities.CanteraTest):
with self.assertRaises(TypeError):
self.phase.TD = 400
with self.assertRaises(AssertionError):
with self.assertRaisesRegex(AssertionError, 'incorrect number'):
self.phase.TP = 300, 101325, 'CH4:1.0'
with self.assertRaises(AssertionError):
with self.assertRaisesRegex(AssertionError, 'incorrect number'):
self.phase.HPY = 1.2e6, 101325
with self.assertRaises(AssertionError):
with self.assertRaisesRegex(AssertionError, 'incorrect number'):
self.phase.UVX = -4e5, 4.4, 'H2:1.0', -1
def test_invalid_property(self):
@ -657,21 +657,21 @@ class TestThermoPhase(utilities.CanteraTest):
ref = ct.Solution('gri30.xml')
reactor = ct.IdealGasReactor(self.phase)
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'Cannot add species'):
self.phase.add_species(ref.species('CH4'))
del reactor
gc.collect()
self.phase.add_species(ref.species('CH4'))
flame = ct.FreeFlame(self.phase, width=0.1)
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'Cannot add species'):
self.phase.add_species(ref.species('CO'))
del flame
gc.collect()
self.phase.add_species(ref.species('CO'))
mix = ct.Mixture([(self.phase, 2.0)])
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'Cannot add species'):
self.phase.add_species(ref.species('CH2O'))
del mix
gc.collect()
@ -679,7 +679,7 @@ class TestThermoPhase(utilities.CanteraTest):
def test_add_species_duplicate(self):
species = self.phase.species('H2O2')
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'already contains'):
self.phase.add_species(species)
@ -916,7 +916,7 @@ ideal_gas(name='spam', elements='O H',
self.assertArrayNear(gas1.X, gas2.X)
def test_checkReactionBalance(self):
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'reaction is unbalanced'):
ct.Solution('h2o2_unbalancedReaction.xml')
@ -1045,24 +1045,24 @@ class TestSpecies(utilities.CanteraTest):
thermo = orig.thermo
copy = ct.Species('foobar', orig.composition)
copy.thermo = thermo
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'modifySpecies'):
self.gas.modify_species(self.gas.species_index('H2'), copy)
copy = ct.Species('H2', {'H': 3})
copy.thermo = thermo
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'modifySpecies'):
self.gas.modify_species(self.gas.species_index('H2'), copy)
copy = ct.Species('H2', orig.composition)
copy.thermo = ct.ConstantCp(thermo.min_temp, thermo.max_temp,
thermo.reference_pressure, [300, 123, 456, 789])
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'modifySpecies'):
self.gas.modify_species(self.gas.species_index('H2'), copy)
copy = ct.Species('H2', orig.composition)
copy.thermo = ct.NasaPoly2(thermo.min_temp+200, thermo.max_temp,
thermo.reference_pressure, thermo.coeffs)
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'modifySpecies'):
self.gas.modify_species(self.gas.species_index('H2'), copy)
@ -1087,7 +1087,7 @@ class TestSpeciesThermo(utilities.CanteraTest):
self.assertNear(st.s(T), self.gas.entropy_mole)
def test_invalid(self):
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'incorrect length'):
# not enough coefficients
st = ct.NasaPoly2(300, 3500, 101325,
[1000.0, 3.03399249E+00, 2.17691804E-03])
@ -1205,7 +1205,7 @@ class TestQuantity(utilities.CanteraTest):
q1 = ct.Quantity(self.gas)
q2 = ct.Quantity(gas2)
with self.assertRaises(ValueError):
with self.assertRaisesRegex(ValueError, 'different phase definitions'):
q1+q2
@ -1249,16 +1249,16 @@ class TestElement(utilities.CanteraTest):
self.assertEqual(self.ar_num.atomic_number, 18)
def test_element_name_not_present(self):
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'element not found'):
ct.Element('I am not an element')
def test_element_atomic_number_small(self):
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'IndexError'):
ct.Element(0)
def test_element_atomic_number_big(self):
num_elements = ct.Element.num_elements_defined
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'IndexError'):
ct.Element(num_elements + 1)
def test_element_bad_input(self):

View file

@ -70,7 +70,7 @@ class TestTransport(utilities.CanteraTest):
self.assertArrayNear(Dbin1, Dbin2)
def test_multiComponent(self):
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'NotImplementedError'):
self.phase.multi_diff_coeffs
self.assertArrayNear(self.phase.thermal_diff_coeffs,
@ -222,7 +222,7 @@ species(name="E",
for geoms in bad:
test = copy.copy(good)
test.update(geoms)
with self.assertRaises(ct.CanteraError):
with self.assertRaisesRegex(ct.CanteraError, 'invalid geometry'):
ct.Solution(source=self.phase_data.format(**test))