Skip to content

Commit

Permalink
Add (currently failing) test for crystal water parsing for 0.8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
bjodah committed Apr 22, 2024
1 parent 578bfb1 commit 21a57ed
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions chempy/tests/test_chemistry.py
Expand Up @@ -570,3 +570,16 @@ def test_balance_stoichiometry__duplicates():
underdetermined=None,
)
assert bal_Mn_COx == ({"CO": 2}, {"C": 1, "CO2": 1})


def test_composition_dot_as_crystal_water_chempy08x():
"""In Chempy v0.8.x a dot will signify crystal water. But an asterisk '*'
or and interpunct (·) is also accepted (and preferred).
From Chempy v0.9.x on-wards, only interpunct and asterisk will be
interpreted as crystal water delimiters, and a dot will be interpreted
as floating point delimiter in fractional stoichiometric coefficients."""
assert chempy.Substance.from_formula('Zn(NO3)2·6H2O').composition == {30: 1, 7: 2, 8: 12, 1: 12}
assert chempy.Substance.from_formula('Zn(NO3)2*6H2O').composition == {30: 1, 7: 2, 8: 12, 1: 12}
# https://docs.pytest.org/en/7.1.x/how-to/capture-warnings.html#ensuring-code-triggers-a-deprecation-warning
with pytest.deprecated_call():
assert chempy.Substance.from_formula('Zn(NO3)2.6H2O').composition == {30: 1, 7: 2, 8: 12, 1: 12}

0 comments on commit 21a57ed

Please sign in to comment.