def test_parse_InvalidElementErrors(arg): r"""Tests that _parse_and_check_atomic_input raises an InvalidElementError when the input corresponds to a valid particle but not a valid element, isotope, or ion.""" with pytest.raises(InvalidElementError): _parse_and_check_atomic_input(arg) pytest.fail("An InvalidElementError was expected to be raised by " f"{call_string(_parse_and_check_atomic_input, arg)}, " f"but no exception was raised.")
def test_parse_InvalidParticleErrors(arg, kwargs): r"""Tests that _parse_and_check_atomic_input raises an InvalidParticleError when the input does not correspond to a real particle.""" with pytest.raises(InvalidParticleError): _parse_and_check_atomic_input(arg, **kwargs) pytest.fail( "An InvalidParticleError was expected to be raised by " f"{call_string(_parse_and_check_atomic_input, arg, kwargs)}, " f"but no exception was raised.")
def test_parse_and_check_atomic_input(arg, kwargs, expected): result = _parse_and_check_atomic_input(arg, **kwargs) assert result == expected, ("Error in _parse_and_check_atomic_input.\n" "The resulting dictionary is:\n\n" f"{result}\n\n" "whereas the expected dictionary is:\n\n" f"{expected}\n")
def test_parse_AtomicWarnings(arg, kwargs, num_warnings): r"""Tests that _parse_and_check_atomic_input issues an AtomicWarning under the required conditions.""" with pytest.warns(ParticleWarning) as record: _parse_and_check_atomic_input(arg, **kwargs) if not record: pytest.fail( f"No AtomicWarning was issued by " f"{_particle_call_string(arg, kwargs)} but the expected number " f"of warnings was {num_warnings}") assert len(record) == num_warnings, ( f"The number of AtomicWarnings issued by {_particle_call_string(arg, kwargs)} " f"was {len(record)}, which differs from the expected number " f"of {num_warnings} warnings.")