-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Be selective with the algorithms that are loaded by Python. Refs #4399
- Loading branch information
1 parent
5846a2a
commit 50b88ec
Showing
4 changed files
with
114 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
Code/Mantid/Framework/PythonInterface/test/python/PythonAlgorithmSubAlgCallTest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
"""A test for the simple API dedicated to Python algorithms. Checks | ||
things like sub-algorithm calls | ||
""" | ||
import unittest | ||
import inspect | ||
import os | ||
import shutil | ||
|
||
|
||
#import mantid.simpleapi as simpleapi | ||
|
||
|
||
class PythonAlgorithmSubAlgCallTest(unittest.TestCase): | ||
|
||
_testdir = os.path.join(os.getcwd(), 'PythonAlgorithmSimpleAPITest_TmpDir') | ||
_parentalg = None | ||
_childalg = None | ||
|
||
def test_subalg_call_of_one_python_call_from_other_suceeds(self): | ||
|
||
|
||
def setUp(self): | ||
__PARENTALG__ = \ | ||
"""from mantid import PythonAlgorithm, registerAlgorithm | ||
class ParentAlgorithm(PythonAlgorithm): | ||
def PyInit(self): | ||
pass | ||
def PyExec(self): | ||
ChildAlgorithm() # If not setup correct this will raise a RuntimeError | ||
registerAlgorithm(ParentAlgorithm) | ||
""" | ||
|
||
__CHILDALG__ = \ | ||
"""from mantid import PythonAlgorithm, registerAlgorithm | ||
class ChildAlgorithm(PythonAlgorithm): | ||
def PyInit(self): | ||
pass | ||
def PyExec(self): | ||
pass | ||
registerAlgorithm(ChildAlgorithm) | ||
""" | ||
try: | ||
os.mkdir(self._testdir) | ||
except OSError: | ||
pass # Already exists, maybe it was not removed when a test failed? | ||
_parentalg = os.path.join(self._testdir, 'ParentAlgorithm.py') | ||
if not os.path.exists(_parentalg): | ||
plugin = file(_parentalg, 'w') | ||
plugin.write(__PARENTALG__) | ||
plugin.close() | ||
_childalg = os.path.join(self._testdir, 'ChildAlgorithm.py') | ||
if not os.path.exists(_parentalg): | ||
plugin = file(_parentalg, 'w') | ||
plugin.write(__CHILDALG__) | ||
plugin.close() | ||
|
||
__import__ | ||
|
||
|
||
def tearDown(self): | ||
try: | ||
shutil.rmtree(self._testdir) | ||
except shutil.Error: | ||
pass | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |