Skip to content

Commit

Permalink
Test that we can make a sample molecule for every atom type.
Browse files Browse the repository at this point in the history
This unit test was inspired by efforts to debug something in some
changes to the database, which caused a segfault when running 
the database Tests, but was in fact caused by an undetected bug in RMG.
  • Loading branch information
rwest committed Jul 22, 2019
1 parent 68367e8 commit 71061b2
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion rmgpy/molecule/atomtypeTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"""

import unittest

import logging
import rmgpy.molecule
from rmgpy.molecule import atomtype, Molecule
from rmgpy.molecule.atomtype import AtomType, getAtomType
Expand Down Expand Up @@ -125,6 +125,21 @@ def testSetActions(self):
self.assertEqual(self.atomType.incrementRadical, other.incrementRadical)
self.assertEqual(self.atomType.decrementRadical, other.decrementRadical)

def testMakeSampleMolecule(self):
"""
Test we can make a sample molecule for every atom type.
"""
failed = []
for name, atom_type in rmgpy.molecule.atomtype.atomTypes.iteritems():
adjlist = "1 {} ux".format(name)
group = rmgpy.molecule.Group().fromAdjacencyList(adjlist)
try:
result = group.makeSampleMolecule()
except:
logging.exception("Couldn't make sample molecule for atomType {}".format(name))
failed.append(name)
self.assertFalse(failed, "Couldn't make sample molecules for types {}".format(','.join(failed)))

################################################################################

class TestGetAtomType(unittest.TestCase):
Expand Down

0 comments on commit 71061b2

Please sign in to comment.