def testBadCharge(self): """Asserts error raise for non-numeric charge input.""" param = ['Ne', '-1.0', '0.0', '+1.0', '?'] with self.assertRaises(ValueError) as e: fileio.GetAtomFromXyzq(param) self.assertEqual(str(e.exception), 'Atomic charge must be numeric value: ?')
def testBadAtomType(self): """Asserts error raise for non-alphanumeric atom type input.""" param = ['_', '0.0', '0.0', '0.0', '0.0'] with self.assertRaises(ValueError) as e: fileio.GetAtomFromXyzq(param) self.assertEqual(str(e.exception), 'Atom type must begin with letter: _')
def testEmptyArray(self): """Asserts error raise for empty string input.""" with self.assertRaises(IndexError) as e: fileio.GetAtomFromXyzq([]) self.assertEqual( str(e.exception), 'Insufficient columns to parse xyzq file row into Atom object: ')
def testBadCoordinate(self): """Asserts error raise for non-numeric coordinate input.""" param = ['C', '0.0', '0.0', 'A', '0.0'] with self.assertRaises(ValueError) as e: fileio.GetAtomFromXyzq(param) self.assertEqual( str(e.exception), 'Atomic coordinates must be numeric values: 0.0 0.0 A')
def testShortArray(self): """Asserts error raise for insufficient string size.""" param = ['H', '0.0', '0.0', '0.0'] with self.assertRaises(IndexError) as e: fileio.GetAtomFromXyzq(param) self.assertEqual( str(e.exception), ('Insufficient columns to parse xyzq file row into Atom object: ' 'H 0.0 0.0 0.0'))
def testArbitrary(self): """Asserts correct output for arbitrary Atom inputs.""" param = ['N*', '999.9', '-0.0001', '2.0', '-0.52'] output = molecule.Atom('N*', [999.9, -0.0001, 2.0], -0.52) test.assertObjectEqual(self, fileio.GetAtomFromXyzq(param), output)
def testZeroValues(self): """Asserts correct output for zero value numeric inputs.""" param = ['OW', '0.0', '0.0', '0.0', '0.0'] output = molecule.Atom('OW', [0.0, 0.0, 0.0], 0.0) test.assertObjectEqual(self, fileio.GetAtomFromXyzq(param), output)