diff --git a/openff/toolkit/_tests/test_forcefield.py b/openff/toolkit/_tests/test_forcefield.py index 278ea6c4c..d2e925634 100644 --- a/openff/toolkit/_tests/test_forcefield.py +++ b/openff/toolkit/_tests/test_forcefield.py @@ -15,6 +15,7 @@ from openff.units.openmm import from_openmm, to_openmm from openmm import NonbondedForce, Platform, XmlSerializer, app from openmm import unit as openmm_unit +from pydantic import ValidationError from openff.toolkit import unit from openff.toolkit._tests.create_molecules import ( @@ -4028,15 +4029,11 @@ def test_fractional_bondorder_invalid_interpolation_method(self): # This error will be either from v1 of the package (if v1 is installed) # or the faked v1 API (if v2 is installed). Ensure the v1 error or a # mimick of it is imported - try: - from pydantic.v1 import ValidationError - except ImportError: - from pydantic import ValidationError # If important, this can be a custom exception instead of a verbose ValidationError with pytest.raises( ValidationError, - match="given=invalid method name", + match="Input should be 'linear'.*input_value='invalid method name'", ): forcefield.create_openmm_system( topology, diff --git a/openff/toolkit/typing/engines/smirnoff/forcefield.py b/openff/toolkit/typing/engines/smirnoff/forcefield.py index 4bfb40529..574f6e39f 100644 --- a/openff/toolkit/typing/engines/smirnoff/forcefield.py +++ b/openff/toolkit/typing/engines/smirnoff/forcefield.py @@ -1399,7 +1399,7 @@ def get_partial_charges(self, molecule: "Molecule", **kwargs: Any) -> Quantity: """ from openff.interchange import Interchange - from openff.toolkit import Molecule, unit + from openff.toolkit import Molecule if not isinstance(molecule, Molecule): raise ValueError( @@ -1412,9 +1412,11 @@ def get_partial_charges(self, molecule: "Molecule", **kwargs: Any) -> Quantity: c.m for c in Interchange.from_smirnoff( force_field=self, topology=[molecule], **kwargs - )["Electrostatics"].charges.values() + )["Electrostatics"] + ._get_charges() + .values() ], - unit.elementary_charge, + "elementary_charge", ) def __getitem__(self, val: Union[str, ParameterHandler]) -> ParameterHandler: