@@ -0,0 +1,2569 @@
+#!/usr/bin/env python%0A# encoding: utf-8 -*-%0A%0A%22%22%22%0AThis module contains unit tests of the rmgpy.parallel module.%0A%22%22%22%0A%0Aimport os%0Aimport sys%0Aimport unittest%0Aimport logging%0A%0Afrom rmgpy import settings%0Afrom rmgpy.data.kinetics import TemplateReaction%0Afrom rmgpy.data.rmg import RMGDatabase, database%0Afrom rmgpy.rmg.main import RMG%0Afrom rmgpy.rmg.model import Species%0A%0Afrom rmgpy.scoop_framework.framework import TestScoopCommon%0A%0Afrom rmgpy.rmg.react import *%0A%0Atry:%0A    from scoop import futures, _control, shared%0Aexcept ImportError, e:%0A    import logging as logging%0A    logging.debug(%22Could not properly import SCOOP.%22)%0A%0ATESTFAMILY = 'H_Abstraction'%0A%0Adef tearDown():%0A    %22%22%22%0A    Reset the loaded database%0A    %22%22%22%0A    import rmgpy.data.rmg%0A    rmgpy.data.rmg.database = None%0A%0Adef load():%0A    %22%22%22%0A    A method that is run before each unit test in this class.%0A    %22%22%22%0A    tearDown()%0A    # set-up RMG object%0A    rmg = RMG()%0A%0A    # load kinetic database and forbidden structures%0A    rmg.database = RMGDatabase()%0A    path = os.path.join(settings%5B'database.directory'%5D)%0A%0A    # forbidden structure loading%0A    rmg.database.loadForbiddenStructures(os.path.join(path, 'forbiddenStructures.py'))%0A    # kinetics family loading%0A    rmg.database.loadKinetics(os.path.join(path, 'kinetics'),%0A                                   kineticsFamilies=%5BTESTFAMILY%5D,%0A                                   reactionLibraries=%5B%5D%0A                                   )%0A%0Adef generate():%0A    %22%22%22%0A    Test that reaction generation from the available families works.%0A    %22%22%22%0A    load()%0A    spcA = Species().fromSMILES('%5BOH%5D')%0A    spcs = %5BSpecies().fromSMILES('CC'), Species().fromSMILES('%5BCH3%5D')%5D%0A%0A    reactionList = list(react(spcA, spcs))%0A%0A    if not reactionList: return False%0A%0A    for rxn in reactionList:%0A        if not isinstance(rxn, TemplateReaction): return False%0A%0A    return True%0A%0Aclass ParallelReactTest(TestScoopCommon):%0A%0A    def __init__(self, *args, **kwargs):%0A        # Parent initialization%0A        super(self.__class__, self).__init__(*args, **kwargs)%0A        %0A        # Only setup the scoop framework once, and not in every test method:%0A        super(self.__class__, self).setUp()%0A    %0A    @unittest.skipUnless(sys.platform.startswith(%22linux%22),%0A                          %22test currently only runs on linux%22)%0A    def test(self):%0A        %22%22%22%0A        Test that we can generate reactions in parallel.%0A        %22%22%22%0A%0A        result = futures._startup(generate)%0A        self.assertEquals(result, True)        %0A%0Aif __name__ == '__main__' and os.environ.get('IS_ORIGIN', %221%22) == %221%22:%0A    unittest.main()%0A

add parallel react Test