from rdkit import Chem
from nose.tools import eq_
from mordred import Calculator, Descriptor
from mordred.error import Error
[docs]class RaiseDescriptor(Descriptor):
[docs] def parameters(self):
return ()
def __init__(self, e, critical):
self.e = e
self.critical = critical
def calculate(self):
raise self.e
mol = Chem.MolFromSmiles('c1ccccc1')
[docs]def test_catch_non_critical_error():
calc = Calculator(RaiseDescriptor(ValueError('test exception'), False))
result = calc(mol)[0]
assert isinstance(result, Error)
eq_(result.error.args, ('test exception',))