Skip to content

Commit 26cfb1e

Browse files
committed
update test_molecule.test_unique_atom_name based on new behavior
1 parent dbc1451 commit 26cfb1e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

openforcefield/tests/test_molecule.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,14 +315,19 @@ def test_to_from_smiles(self, molecule, toolkit):
315315
@pytest.mark.parametrize('molecule', mini_drug_bank())
316316
def test_unique_atom_names(self, molecule):
317317
"""Test molecules have unique atom names"""
318-
smiles1 = molecule.to_smiles()
319-
molecule2 = Molecule.from_smiles(smiles1)
318+
# The dataset we load in has atom names, so let's strip them first
319+
# to ensure that we can fail the uniqueness check
320+
for atom in molecule.atoms:
321+
atom.name = ''
322+
assert not(molecule.has_unique_atom_names)
323+
# Then genreate unique atom names using the built in algorithm
324+
molecule.generate_unique_atom_names()
320325
# Check that the molecule has unique atom names
321-
assert (molecule2.has_unique_atom_names == True)
326+
assert molecule.has_unique_atom_names
322327
# Check molecule.has_unique_atom_names is working correctly
323-
assert ((len(set([atom.name for atom in molecule2.atoms])) == molecule2.n_atoms) == molecule2.has_unique_atom_names)
324-
molecule2.atoms[1].name = molecule2.atoms[0].name # no longer unique
325-
assert ((len(set([atom.name for atom in molecule2.atoms])) == molecule2.n_atoms) == molecule2.has_unique_atom_names)
328+
assert ((len(set([atom.name for atom in molecule.atoms])) == molecule.n_atoms) == molecule.has_unique_atom_names)
329+
molecule.atoms[1].name = molecule.atoms[0].name # no longer unique
330+
assert ((len(set([atom.name for atom in molecule.atoms])) == molecule.n_atoms) == molecule.has_unique_atom_names)
326331

327332
# TODO: Should there be an equivalent toolkit test and leave this as an integration test?
328333
@pytest.mark.slow

0 commit comments

Comments
 (0)