diff --git a/modules/base/doc/testutils.rst b/modules/base/doc/testutils.rst index df61f56e7302da580e9b64d1b4235564057a1370..dabf827e63eddd10b844a894c2d2de2dfcfa099f 100644 --- a/modules/base/doc/testutils.rst +++ b/modules/base/doc/testutils.rst @@ -6,4 +6,4 @@ .. autofunction:: ost.testutils.RunTests -.. autofunction:: ost.testutils.SetDefaultCompoundLib +.. autofunction:: ost.testutils.DefaultCompoundLibIsSet diff --git a/modules/base/pymod/testutils.py b/modules/base/pymod/testutils.py index 4b701fe08fa6ae71e1648bd1330a2a907c777bb9..af5f7b66cb356ece03850699906cd83ae0aef54f 100644 --- a/modules/base/pymod/testutils.py +++ b/modules/base/pymod/testutils.py @@ -54,54 +54,16 @@ def RunTests(): print(e) -def SetDefaultCompoundLib(): +def DefaultCompoundLibIsSet(): ''' - This function tries to ensure that a default compound library is set. - When calling scripts with ``ost`` this is not needed, but since unit tests are - called with ``python`` we need to ensure that it is set. The function is only - expected to succeed (and return True) if ``COMPOUND_LIB`` was set when - :ref:`configuring the compilation <cmake-flags>`. - - It tries the following: - - - get it with :func:`ost.conop.GetDefaultLib` - - look for ``compounds.chemlib`` in ``$OST_ROOT/share/openstructure`` - - if ``OST_ROOT`` not set in the above, try to guess it based on the path of - the ``conop`` module - - To use this check modify the :func:`RunTests` call to read: - - .. code-block:: python - - if __name__ == "__main__": - from ost import testutils - if testutils.SetDefaultCompoundLib(): - testutils.RunTests() - else: - print 'No compound library available. Ignoring test_XXX.py tests.' + This function checks if a default compound library is set. :return: True, if a compound library was found and set to be accessed with :func:`ost.conop.GetDefaultLib`. False otherwise. ''' - import os - from ost import conop, GetSharedDataPath, SetPrefixPath + from ost. conop import GetDefaultLib # check if already there - if conop.GetDefaultLib(): + if GetDefaultLib(): return True else: - # try to get the shared data path? - try: - shared_data_path = GetSharedDataPath() - except Exception as e: - SetPrefixPath(os.path.abspath(os.path.join(conop.__path__[0], os.pardir, - os.pardir, os.pardir, - os.pardir, os.pardir))) - shared_data_path = GetSharedDataPath() - # look for compounds.chemlib in there - compound_lib_path = os.path.join(shared_data_path, 'compounds.chemlib') - if os.path.exists(compound_lib_path): - compound_lib = conop.CompoundLib.Load(compound_lib_path) - conop.SetDefaultLib(compound_lib) - return True - else: - return False + return False diff --git a/modules/conop/tests/test_cleanup.py b/modules/conop/tests/test_cleanup.py index 54d33a8bc67bf1b95d2df425ea76b8ac5927a09c..3abc1f5ffad1908934d833be586ac3e6794571be 100644 --- a/modules/conop/tests/test_cleanup.py +++ b/modules/conop/tests/test_cleanup.py @@ -160,7 +160,7 @@ class TestCleanUp(unittest.TestCase): if __name__ == "__main__": from ost import testutils - if testutils.SetDefaultCompoundLib(): + if testutils.DefaultCompoundLibIsSet(): testutils.RunTests() else: print('No compound library available. Ignoring test_cleanup.py tests.') diff --git a/modules/conop/tests/test_complib.py b/modules/conop/tests/test_complib.py index dca8dc3e920b6c9c830419553016e31ead5db032..2c3e3f8121c2ea6d678a1edf67b9e0fbf1469dbf 100644 --- a/modules/conop/tests/test_complib.py +++ b/modules/conop/tests/test_complib.py @@ -31,7 +31,7 @@ class TestCompLib(unittest.TestCase): if __name__ == "__main__": from ost import testutils - if testutils.SetDefaultCompoundLib(): + if testutils.DefaultCompoundLibIsSet(): testutils.RunTests() else: print('No compound lib available. Ignoring test_complib tests.') \ No newline at end of file diff --git a/modules/conop/tests/test_compound.py b/modules/conop/tests/test_compound.py index 01c59a233e263e1c9d538c6ae303a7cf5442a8d3..a6c704d408d1c3926a786e3e4f0988b6ddfbfcf2 100644 --- a/modules/conop/tests/test_compound.py +++ b/modules/conop/tests/test_compound.py @@ -25,7 +25,7 @@ class TestCompound(unittest.TestCase): if __name__=='__main__': from ost import testutils - if testutils.SetDefaultCompoundLib(): + if testutils.DefaultCompoundLibIsSet(): testutils.RunTests() else: print('No compound library available. Ignoring test_compound.py tests.') \ No newline at end of file diff --git a/modules/io/tests/test_io_omf.py b/modules/io/tests/test_io_omf.py index 1ed14044a23919d8f9624254a7d270db2d815a8d..8d519c5084969316d2aeab844aeac45cdd89d8bd 100644 --- a/modules/io/tests/test_io_omf.py +++ b/modules/io/tests/test_io_omf.py @@ -248,7 +248,7 @@ class TestOMF(unittest.TestCase): if __name__== '__main__': from ost import testutils - if testutils.SetDefaultCompoundLib(): + if testutils.DefaultCompoundLibIsSet(): testutils.RunTests() else: print('No compound library available. Ignoring test_stereochemistry.py tests.') diff --git a/modules/mol/alg/tests/test_chain_mapping.py b/modules/mol/alg/tests/test_chain_mapping.py index 8c8846aba8a3de61c6a52991c33041186b00219e..16fd363e596e42a180cacf049ef444390a05816c 100644 --- a/modules/mol/alg/tests/test_chain_mapping.py +++ b/modules/mol/alg/tests/test_chain_mapping.py @@ -362,7 +362,7 @@ class TestChainMapper(unittest.TestCase): if __name__ == "__main__": from ost import testutils - if testutils.SetDefaultCompoundLib(): + if testutils.DefaultCompoundLibIsSet(): testutils.RunTests() else: print('No compound lib available. Ignoring test_chain_mapping.py tests.') diff --git a/modules/mol/alg/tests/test_lddt.py b/modules/mol/alg/tests/test_lddt.py index cb8f1d28ad8c910d44954e05758d11c769503607..6cfe9d5b6ba1e5f6b71d37898e15f1f5147eac0c 100644 --- a/modules/mol/alg/tests/test_lddt.py +++ b/modules/mol/alg/tests/test_lddt.py @@ -276,7 +276,7 @@ class TestlDDTBS(unittest.TestCase): if __name__ == "__main__": from ost import testutils - if testutils.SetDefaultCompoundLib(): + if testutils.DefaultCompoundLibIsSet(): testutils.RunTests() else: print('No compound library available. Ignoring test_lddt.py tests.') diff --git a/modules/mol/alg/tests/test_ligand_scoring.py b/modules/mol/alg/tests/test_ligand_scoring.py index b23de7b9c49bac4af17fe06781d23fd601ba59ca..a1de22761d0dc52749a68d20fc758a5e49c45a2b 100644 --- a/modules/mol/alg/tests/test_ligand_scoring.py +++ b/modules/mol/alg/tests/test_ligand_scoring.py @@ -341,7 +341,7 @@ class TestLigandScoring(unittest.TestCase): if __name__ == "__main__": from ost import testutils - if testutils.SetDefaultCompoundLib(): + if testutils.DefaultCompoundLibIsSet(): testutils.RunTests() else: print('No compound lib available. Ignoring test_ligand_scoring.py tests.') diff --git a/modules/mol/alg/tests/test_nonstandard.py b/modules/mol/alg/tests/test_nonstandard.py index c7f49215eb79b559c1c43cd71659569de5e447fb..99bf7fdd0a8284986e4d4bb546de42a2d58193a2 100644 --- a/modules/mol/alg/tests/test_nonstandard.py +++ b/modules/mol/alg/tests/test_nonstandard.py @@ -163,7 +163,7 @@ class TestNonStandard(unittest.TestCase): if __name__ == "__main__": from ost import testutils - if testutils.SetDefaultCompoundLib(): + if testutils.DefaultCompoundLibIsSet(): testutils.RunTests() else: print('No compound library available. Ignoring test_nonstandard.py tests.') diff --git a/modules/mol/alg/tests/test_qsscore.py b/modules/mol/alg/tests/test_qsscore.py index 34ba726ad41926866a292c28174bebc05c3ac82e..5aed15ee8eb8f2591876b8862431e1680a41e88b 100644 --- a/modules/mol/alg/tests/test_qsscore.py +++ b/modules/mol/alg/tests/test_qsscore.py @@ -264,7 +264,7 @@ class TestQSScore(unittest.TestCase): if __name__ == "__main__": from ost import testutils - if testutils.SetDefaultCompoundLib(): + if testutils.DefaultCompoundLibIsSet(): testutils.RunTests() else: print('No compound lib available. Ignoring test_qsscore.py tests.') diff --git a/modules/mol/alg/tests/test_qsscoring.py b/modules/mol/alg/tests/test_qsscoring.py index 31daffe565ed5ac3d3cb8cf59ecb76dee7e62534..fc73c72d6b72a34dacb0365997460eba9c9e2a1d 100644 --- a/modules/mol/alg/tests/test_qsscoring.py +++ b/modules/mol/alg/tests/test_qsscoring.py @@ -706,7 +706,7 @@ if __name__ == "__main__": print("Could not find ClustalW. Ignoring test_qsscoring.py tests.") sys.exit(0) from ost import testutils - if testutils.SetDefaultCompoundLib(): + if testutils.DefaultCompoundLibIsSet(): testutils.RunTests() else: print('No compound library available. Ignoring test_qsscoring.py tests.') diff --git a/modules/mol/alg/tests/test_stereochemistry.py b/modules/mol/alg/tests/test_stereochemistry.py index ae458d4b5e696f71e57f1fe2cc9b500cf19225bb..b449c669bd641771681ff4f4edc8bec2f683cc93 100644 --- a/modules/mol/alg/tests/test_stereochemistry.py +++ b/modules/mol/alg/tests/test_stereochemistry.py @@ -209,7 +209,7 @@ class TestStereochemistry(unittest.TestCase): if __name__ == "__main__": from ost import testutils - if testutils.SetDefaultCompoundLib(): + if testutils.DefaultCompoundLibIsSet(): testutils.RunTests() else: print('No compound library available. Ignoring test_stereochemistry.py tests.') diff --git a/modules/seq/alg/tests/test_aaindex.py b/modules/seq/alg/tests/test_aaindex.py index a1915e28e3e7564525159a98dd34216b0e4c7a0b..2fcd8002c6163f60eff1a4d6bc43c974d27a0d26 100644 --- a/modules/seq/alg/tests/test_aaindex.py +++ b/modules/seq/alg/tests/test_aaindex.py @@ -45,5 +45,5 @@ if __name__ == "__main__": from ost import testutils # the function below indirectly enables GetSharedDataPath when # calling stuff from python which is the case in unit tests - testutils.SetDefaultCompoundLib() + testutils.DefaultCompoundLibIsSet() testutils.RunTests() diff --git a/modules/seq/alg/tests/test_aligntoseqres.py b/modules/seq/alg/tests/test_aligntoseqres.py index 5664ff8378a30667bf543d2463b2a6c29a51b385..642edb8056cba4341a1a0ce6cd1f25323add6c23 100644 --- a/modules/seq/alg/tests/test_aligntoseqres.py +++ b/modules/seq/alg/tests/test_aligntoseqres.py @@ -68,7 +68,7 @@ class TestAlignToSeqRes(unittest.TestCase): if __name__ == "__main__": from ost import testutils - if testutils.SetDefaultCompoundLib(): + if testutils.DefaultCompoundLibIsSet(): testutils.RunTests() else: print('No compound library available. Ignoring test_aligntoseqres.py tests.')