<commit_before>import os, unittest
from cclib.parser import GAMESS,G03,ADF
from Numeric import array

class GenericTest(unittest.TestCase):
    def testhomos(self):
        self.assertEquals(self.data.homos,array([34]))

    def testnatom(self):
        self.assertEquals(self.data.natom,20)

    def testnbasis(self):
        self.assertEquals(self.data.nbasis,60)

    def testscfenergy(self):
        self.assert_(self.data.scfenergies[-1]+382.3<3)

    def testhomoenergy(self):
        self.assert_(self.data.moenergies[0,self.data.homos[0]]+4.165<0.5,"HOMO energy is %f (for G03 it's -4.165)" % self.data.moenergies[0,self.data.homos[0]])

class GaussianTest(GenericTest):
    def setUp(self):
        self.data = G03(os.path.join("..","data","Gaussian","basicGaussian03","dvb_gopt.out"))
        self.data.logger.setLevel(0)
        self.data.parse()

class GamessTest(GenericTest):
    def setUp(self):
        self.data = GAMESS(os.path.join("..","data","GAMESS","basicPCGAMESS","dvb_gopt_a.out"))
        self.data.logger.setLevel(0)
        self.data.parse()

class ADFTest(GenericTest):
    def setUp(self):
        self.data = ADF(os.path.join("..","data","ADF","basicADF2004.01","dvb_gopt.adfout"))
        self.data.logger.setLevel(0)
        self.data.parse()
    <commit_msg>Added convenience function to make it easier to access the data files in the data folder.<commit_after>import os, unittest
from cclib.parser import GAMESS,G03,ADF
from Numeric import array

class GenericTest(unittest.TestCase):
    def testhomos(self):
        self.assertEquals(self.data.homos,array([34]))

    def testnatom(self):
        self.assertEquals(self.data.natom,20)

    def testnbasis(self):
        self.assertEquals(self.data.nbasis,60)

    def testscfenergy(self):
        self.assert_(self.data.scfenergies[-1]+382.3<3)

    def testhomoenergy(self):
        self.assert_(self.data.moenergies[0,self.data.homos[0]]+4.165<0.5,"HOMO energy is %f (for G03 it's -4.165)" % self.data.moenergies[0,self.data.homos[0]])

class GaussianTest(GenericTest):
    def setUp(self):
        self.data = getfile(G03,"basicGaussian03","dvb_gopt.out")

class GamessTest(GenericTest):
    def setUp(self):
        self.data = getfile(GAMESS,"basicPCGAMESS","dvb_gopt_a.out")

class ADFTest(GenericTest):
    def setUp(self):
        self.data = getfile(ADF,"basicADF2004.01","dvb_gopt.adfout")

def getfile(parser,*location):
    """Returns a parsed logfile."""
    if parser.__name__ in ['GAMESS','ADF']:
        fullpath = ("..","data",parser.__name__) + location
    elif parser.__name__=="G03":
        fullpath = ("..","data","Gaussian") + location
    logfile = parser(os.path.join(*fullpath))
    logfile.logger.setLevel(0)
    logfile.parse()
    return logfile

def visualtests():
    """These are not formal tests -- but they should be eyeballed."""
    pass
    
    
{'fraction_non_alphanumeric': 0.15430163706025776, 'fraction_numerical': 0.029954719609892023, 'mean_word_length': 3.632258064516129, 'pattern_counts': {'":': 1, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1496466', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1002, 'n_words': 166}